From bfd64221491e9b5fee5da5f9c12389e8874ea256 Mon Sep 17 00:00:00 2001 From: Albrecht Degering Date: Tue, 1 Sep 2026 02:39:44 +0200 Subject: [PATCH] Release Privacy Tools 0.1.0 --- .gitignore | 9 + .npmrc | 1 + CHANGELOG.md | 21 + CONTRIBUTING.md | 3 + LICENSE | 674 +++++ LICENSES/README.md | 3 + README.md | 118 + SECURITY.md | 33 + SOURCE.md | 23 + THIRD_PARTY_NOTICES.md | 23 + docs/ACCESSIBILITY.md | 16 + docs/ARCHITECTURE.md | 49 + docs/PRIVACY-SECURITY.md | 59 + eslint.config.mjs | 37 + index.html | 19 + package-lock.json | 3524 ++++++++++++++++++++++ package.json | 73 + playwright.config.ts | 21 + public/CHANGELOG.md | 21 + public/CONTRIBUTING.md | 3 + public/LICENSE | 674 +++++ public/LICENSES/README.md | 3 + public/LICENSES/npm-runtime-licenses.txt | 1583 ++++++++++ public/README.md | 118 + public/SECURITY.md | 33 + public/SOURCE.md | 23 + public/THIRD_PARTY_NOTICES.md | 23 + public/docs/ACCESSIBILITY.md | 16 + public/docs/ARCHITECTURE.md | 49 + public/docs/PRIVACY-SECURITY.md | 59 + public/favicon.svg | 1 + public/manifest.webmanifest | 18 + public/sw.js | 54 + public/toolbox-app.json | 41 + scripts/generate-toolbox-manifest.mjs | 33 + scripts/package-release.mjs | 165 + scripts/prepare-release-files.mjs | 70 + scripts/serve-test.mjs | 66 + src/App.tsx | 35 + src/components/ErrorBoundary.tsx | 27 + src/components/HelpDialog.tsx | 77 + src/components/Workbench.tsx | 687 +++++ src/main.tsx | 18 + src/privacy/archive.ts | 121 + src/privacy/detect.ts | 149 + src/privacy/exif-reader-adapter.ts | 141 + src/privacy/findings.ts | 159 + src/privacy/index.ts | 7 + src/privacy/inflate.ts | 29 + src/privacy/iptc.ts | 128 + src/privacy/jpeg.ts | 323 ++ src/privacy/limits.ts | 73 + src/privacy/model.ts | 156 + src/privacy/png.ts | 359 +++ src/privacy/sanitize.ts | 435 +++ src/privacy/scan-client.ts | 112 + src/privacy/scanner.ts | 151 + src/privacy/tiff.ts | 346 +++ src/privacy/webp.ts | 189 ++ src/privacy/xmp.ts | 94 + src/styles.css | 757 +++++ src/test/setup.ts | 8 + src/toolbox/manifest.source.json | 41 + src/toolbox/manifest.ts | 4 + src/version.ts | 1 + src/vite-env.d.ts | 1 + src/worker/protocol.ts | 21 + src/worker/scan.worker.ts | 31 + tests/browser/app.spec.ts | 166 + tests/components/app.test.tsx | 18 + tests/fixtures/images.ts | 253 ++ tests/privacy/detect.test.ts | 48 + tests/privacy/limits.test.ts | 40 + tests/privacy/report.test.ts | 207 ++ tests/privacy/scanner.test.ts | 236 ++ tsconfig.app.json | 27 + tsconfig.json | 11 + tsconfig.node.json | 24 + vite.config.ts | 16 + 79 files changed, 13485 insertions(+) create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 LICENSES/README.md create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 SOURCE.md create mode 100644 THIRD_PARTY_NOTICES.md create mode 100644 docs/ACCESSIBILITY.md create mode 100644 docs/ARCHITECTURE.md create mode 100644 docs/PRIVACY-SECURITY.md create mode 100644 eslint.config.mjs create mode 100644 index.html create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 playwright.config.ts create mode 100644 public/CHANGELOG.md create mode 100644 public/CONTRIBUTING.md create mode 100644 public/LICENSE create mode 100644 public/LICENSES/README.md create mode 100644 public/LICENSES/npm-runtime-licenses.txt create mode 100644 public/README.md create mode 100644 public/SECURITY.md create mode 100644 public/SOURCE.md create mode 100644 public/THIRD_PARTY_NOTICES.md create mode 100644 public/docs/ACCESSIBILITY.md create mode 100644 public/docs/ARCHITECTURE.md create mode 100644 public/docs/PRIVACY-SECURITY.md create mode 100644 public/favicon.svg create mode 100644 public/manifest.webmanifest create mode 100644 public/sw.js create mode 100644 public/toolbox-app.json create mode 100644 scripts/generate-toolbox-manifest.mjs create mode 100644 scripts/package-release.mjs create mode 100644 scripts/prepare-release-files.mjs create mode 100644 scripts/serve-test.mjs create mode 100644 src/App.tsx create mode 100644 src/components/ErrorBoundary.tsx create mode 100644 src/components/HelpDialog.tsx create mode 100644 src/components/Workbench.tsx create mode 100644 src/main.tsx create mode 100644 src/privacy/archive.ts create mode 100644 src/privacy/detect.ts create mode 100644 src/privacy/exif-reader-adapter.ts create mode 100644 src/privacy/findings.ts create mode 100644 src/privacy/index.ts create mode 100644 src/privacy/inflate.ts create mode 100644 src/privacy/iptc.ts create mode 100644 src/privacy/jpeg.ts create mode 100644 src/privacy/limits.ts create mode 100644 src/privacy/model.ts create mode 100644 src/privacy/png.ts create mode 100644 src/privacy/sanitize.ts create mode 100644 src/privacy/scan-client.ts create mode 100644 src/privacy/scanner.ts create mode 100644 src/privacy/tiff.ts create mode 100644 src/privacy/webp.ts create mode 100644 src/privacy/xmp.ts create mode 100644 src/styles.css create mode 100644 src/test/setup.ts create mode 100644 src/toolbox/manifest.source.json create mode 100644 src/toolbox/manifest.ts create mode 100644 src/version.ts create mode 100644 src/vite-env.d.ts create mode 100644 src/worker/protocol.ts create mode 100644 src/worker/scan.worker.ts create mode 100644 tests/browser/app.spec.ts create mode 100644 tests/components/app.test.tsx create mode 100644 tests/fixtures/images.ts create mode 100644 tests/privacy/detect.test.ts create mode 100644 tests/privacy/limits.test.ts create mode 100644 tests/privacy/report.test.ts create mode 100644 tests/privacy/scanner.test.ts create mode 100644 tsconfig.app.json create mode 100644 tsconfig.json create mode 100644 tsconfig.node.json create mode 100644 vite.config.ts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..177f475 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +node_modules/ +dist/ +release/*.zip +release/*.zip.sha256 +coverage/ +playwright-report/ +test-results/ +*.tsbuildinfo +.DS_Store diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..7e977af --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@add-ideas:registry=https://git.add-ideas.de/api/packages/lotobo/npm/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e911593 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +## 0.1.0 - 2026-09-01 + +- Added byte-signature inventory, claimed-vs-detected media types, safe names, + SHA-256 hashes, and bounded batches. +- Added project-owned JPEG, PNG, WebP, EXIF/TIFF, IPTC, and XMP scanners with + explicit structural and decompression limits. +- Added ExifReader as a second scanner and best-effort inspect-only coverage for + TIFF, HEIC/HEIF, AVIF, and JPEG XL. +- Added categorized metadata findings, coverage and warning reports, including + selected colour-profile, thumbnail, trailing-data, MPF, JUMBF, and C2PA + indicators. +- Added orientation-normalized pixel re-encoding for supported static JPEG, PNG, + and WebP images, followed by mandatory output hashing, independent re-scan, + dimension/orientation checks, and a bounded pixel-sample comparison. +- Added individual outputs, deterministic JSON reports, bounded batch ZIPs, + cancellation, Toolbox shell integration, offline static packaging, and + explicit no-anonymity boundaries. +- Added generated format/adversarial fixtures, unit gates, and Chromium/Firefox + nested-path and no-network browser gates. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..1438c5d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +Run `npm ci`, `npm run check`, and `npm run test:browser` before proposing a change. Keep processing local, preserve explicit limits, and include fixtures for every parser boundary. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/LICENSES/README.md b/LICENSES/README.md new file mode 100644 index 0000000..efbd7a1 --- /dev/null +++ b/LICENSES/README.md @@ -0,0 +1,3 @@ +# Licences + +The application is GPL-3.0-or-later. Generated release artifacts include an exact runtime dependency licence inventory in `npm-runtime-licenses.txt`. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a1c415f --- /dev/null +++ b/README.md @@ -0,0 +1,118 @@ +# Privacy Tools + +Privacy Tools is a standalone, local-first browser workbench for inspecting +image metadata and producing deliberately re-encoded sharing copies. It is part +of the [add·ideas Toolbox](https://git.add-ideas.de/lotobo/toolbox-portal), but +the static release also runs independently at any nested path. + +Selected files stay in the browser. There are no accounts, analytics, remote +lookups, telemetry, or runtime network calls. A source file is never modified. + +## Version 0.1 workflow + +1. Select or drop a bounded batch. Every file gets a safe display/download name, + SHA-256 hash, byte-signature type detection, and claimed-vs-detected type + result. +2. Review categorized findings, parser coverage, dimensions, animation or + multi-image status, and warnings. +3. For a supported static JPEG, PNG, or WebP, explicitly re-encode the decoded + pixels. EXIF orientation is normalized; source container blocks, embedded + thumbnails, trailing bytes, and source profiles are not copied. +4. An independently parsed output is mandatory. The result states what was + removed, preserved, generated, unsupported, or incompletely checked, and + includes source/output SHA-256 hashes and a bounded decoded-pixel sample + comparison. +5. Download an individual re-encoded image, a JSON report, or a ZIP containing + re-encoded images and the report. The report itself may be sensitive because + it contains source filenames and metadata values. + +## Format support + +| Format | Inventory | Deep project scan | Secondary scan | Pixel re-encode | +| ------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------ | +| Static JPEG | Yes | EXIF/TIFF, IPTC/Photoshop, XMP, JFIF, ICC, COM, MPF, selected JUMBF/C2PA and trailing bytes | ExifReader | JPEG | +| Static PNG | Yes | tEXt, zTXt, iTXt/XMP, eXIf/TIFF, iCCP, pHYs, tIME, private/unknown ancillary chunks, selected caBX/C2PA and trailing bytes | ExifReader | PNG | +| Static WebP | Yes | RIFF/VP8 dimensions, EXIF/TIFF, XMP, ICC, META, animation and trailing bytes | ExifReader | WebP where the browser encoder supports it | +| TIFF, HEIC/HEIF, AVIF, JPEG XL | Yes | No | Best-effort ExifReader inspection | No | +| GIF | Yes | No | No supported deep adapter | No | +| PDF, ZIP/Office, OLE/legacy Office, unknown | Yes | No | No | No | + +Animation, multi-picture JPEG/MPF, and malformed or partially scanned +JPEG/PNG/WebP inputs are inspect-only. Secondary coverage depends on what +ExifReader can establish for the particular container. A browser may decode a +format it cannot encode; that still does not make it eligible for output. + +Findings are grouped as location; people/authorship/rights; dates; device, +serial and lens; software/history; document identifiers; comments/titles/ +keywords; embedded previews; colour profiles; provenance; technical; or +unclassified. Raw XMP is shown only as bounded inert text—never injected as +markup. + +## Security boundaries and limits + +Inputs are untrusted. Container parsing runs in a terminable worker and checks +declared lengths, CRCs, offsets, TIFF cycles/depth/counts, chunk/segment counts, +compressed metadata expansion, dimensions, and aggregate batch size before +continuing. Defaults are 100 files, 128 MiB per file, 512 MiB per batch, 4,096 +metadata blocks/findings, 8 MiB per metadata block, 4 MiB decompressed metadata, +512-character labels, 16,384-character values, 256 KiB normalized finding text +per file, 40 megapixels, a 32,768-pixel edge, and a 256 MiB ZIP payload. + +The pixel decode/encode step uses browser-native image and Canvas APIs. It runs +only after a complete project scan and bounded dimensions. The output gate does +not trust successful encoding: it hashes and scans the newly encoded bytes +again. C2PA/JUMBF provenance is authenticity information rather than ordinary +tracking metadata; pixel re-encoding removes or invalidates it, and the report +calls that out. + +This is not an anonymity tool. Metadata removal does not remove visible faces +or text, steganography, invisible or forensic watermarks, reverse-image +matching, sidecar files, filesystem history, application caches, or cloud and +recipient copies. JPEG and lossy WebP output may alter pixels. Colour profiles, +resolution metadata, and provenance may be lost. Inspect the actual output and +report before sharing it. + +See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) and +[docs/PRIVACY-SECURITY.md](docs/PRIVACY-SECURITY.md) for the implementation and +threat model. + +## Browser and accessibility support + +Current evergreen Chromium and Firefox are exercised in the browser gate; +current Safari is an intended target. JavaScript modules, Web Workers, Blob, +Canvas 2D, `createImageBitmap` where available, and Web Crypto are used. WebP +output follows browser encoder support. The application supports the shared +Toolbox system/light/dark themes, keyboard file selection, native table and +disclosure semantics, visible focus, live progress, and non-colour status text. + +## Development + +Requirements: Node.js 22 or newer and npm 11 or newer. + +```sh +npm ci +npm run check +npm run test:browser +npm run dev +``` + +Vite uses `base: './'`, so `dist/` can be hosted at `/` or below a nested +Toolbox path. `toolbox-check` validates the production manifest and bundle. + +## Release + +```sh +npm run release:artifact +``` + +This checks the manifest, types, lint, formatting, unit fixtures, production +build, Toolbox contract, and Chromium/Firefox workflows, then creates the +deterministic `release/privacy-tools-0.1.0.zip` plus its SHA-256 sidecar. The +archive contains the static application, project documents, and exact runtime +dependency licence texts. + +## Licence + +Privacy Tools is free software under `GPL-3.0-or-later`; see [LICENSE](LICENSE). +Runtime dependencies keep their licences, including ExifReader under MPL-2.0. +See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..63624f0 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,33 @@ +# Security + +Report vulnerabilities privately to the repository owner. Do not attach a +sensitive source image, generated report, or real metadata to a public issue; +construct a minimal synthetic reproduction instead. + +## Input model + +Every selected file and every metadata value is untrusted. The application +detects containers from bytes, does not execute imported content, renders text +through React rather than raw HTML, performs no metadata-linked fetches, and +does not preserve source blocks in a re-encoded output. The scanning worker can +be terminated on cancellation. Browser-native pixel decoding remains part of +the browser's trusted computing base. + +Default bounds cover file/batch bytes, container blocks, individual metadata, +decompressed PNG metadata, finding lengths/counts, TIFF offsets/entries/depth, +pixel count/edge, and batch ZIP size. Malformed structures become partial or +failed coverage; they must never receive clean-copy eligibility or a verified +output result. + +## Output model + +A successful Canvas encode is not sufficient. The new bytes are independently +hashed and scanned, expected oriented dimensions are checked, sensitive or +provenance findings fail the verification gate, and incomplete coverage is +reported. C2PA/JUMBF signatures are expected to be removed or invalidated by +pixel re-encoding. Reports and output names are escaped/sanitized and ZIP paths +are application-generated. + +No status is an anonymity guarantee. Visible content, steganography, invisible +watermarks, image fingerprinting, sidecars, local filesystem metadata, browser +history, and remote copies are outside the scan. diff --git a/SOURCE.md b/SOURCE.md new file mode 100644 index 0000000..618fc8c --- /dev/null +++ b/SOURCE.md @@ -0,0 +1,23 @@ +# Corresponding source + +The corresponding source for Privacy Tools 0.1.0 is published at: + +https://git.add-ideas.de/lotobo/privacy-tools/src/tag/v0.1.0 + +Build with Node.js 22 and npm 11: + +```sh +npm ci +npm run release:artifact +``` + +The release command performs all source, test, browser, manifest, and Toolbox +checks before assembling the deterministic static ZIP. The artifact includes +this file, the GPL licence, project documentation, and the runtime dependency +licence texts generated from the exact lockfile. + +ExifReader 4.44.0 is unmodified MPL-2.0 covered software within the bundled +application. Its preferred source form is available from the exact npm package +and upstream release identified in `package-lock.json` and +`THIRD_PARTY_NOTICES.md`; its MPL licence text is included in the generated +runtime licence inventory. diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..ef8a284 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,23 @@ +# Third-party notices + +Privacy Tools is GPL-3.0-or-later. Dependencies retain their own licences. A +production build generates `LICENSES/npm-runtime-licenses.txt` from the exact +locked runtime packages and copies every available licence/notice text into the +release. + +Material runtime components include: + +| Component | Version | Licence | Purpose/source | +| -------------------------------- | ------- | ---------------- | -------------------------------------------------------------------------------------------------- | +| ExifReader | 4.44.0 | MPL-2.0 | Secondary metadata parser; | +| fflate | 0.8.2 | MIT | Bounded PNG metadata inflation and ZIP creation; | +| `@add-ideas/toolbox-helpers` | 0.1.0 | GPL-3.0-or-later | Hashing, safe names, download and deterministic JSON primitives | +| `@add-ideas/toolbox-contract` | 0.2.3 | Apache-2.0 | Toolbox manifest contract | +| `@add-ideas/toolbox-shell-react` | 0.2.3 | Apache-2.0 | Shared application shell | +| React / React DOM | 19.2.8 | MIT | User interface | + +ExifReader is used unmodified. Its MPL-2.0 covered source remains available at +the exact upstream link above and through the npm package resolved by the +lockfile. The bundled executable does not relicense or restrict the MPL-covered +files. Consult the generated licence inventory for the full MPL-2.0 text and +the exact notices shipped with every runtime package. diff --git a/docs/ACCESSIBILITY.md b/docs/ACCESSIBILITY.md new file mode 100644 index 0000000..f1afd0e --- /dev/null +++ b/docs/ACCESSIBILITY.md @@ -0,0 +1,16 @@ +# Accessibility + +The workbench uses semantic landmarks, headings, a native multiple-file input, +buttons, tables, definition lists, progress, status/alert regions, and native +disclosures/dialogs. All workflows are keyboard operable; drop is an optional +pointer shortcut. Visible focus and the shared Toolbox system/light/dark themes +are preserved. + +Status is always written as text and never encoded by colour alone. Finding +categories expose labels and counts, hashes and media types remain selectable, +and responsive layouts allow horizontal table scrolling without clipping the +whole page. Motion is not required to understand progress or results. + +Automated component and Chromium/Firefox browser gates cover semantics and core +workflows. They supplement, rather than replace, manual keyboard, zoom, +screen-reader, high-contrast, and reduced-motion review before release. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md new file mode 100644 index 0000000..8affc35 --- /dev/null +++ b/docs/ARCHITECTURE.md @@ -0,0 +1,49 @@ +# Architecture + +Privacy Tools is a relocatable Vite/React static application. The core domain +model in `src/privacy` is serializable: scan inputs cross a worker boundary as +transferred `ArrayBuffer`s and results contain only strings, numbers, booleans, +arrays, and plain objects. No parser returns HTML or a live third-party object. + +## Pipeline + +1. `scan-client` checks file count and declared byte totals before reading the + batch, transfers buffers to a dedicated worker, reports progress, and + terminates the worker on cancellation. +2. `detect` compares magic bytes, filename extension, and browser-claimed MIME. + `scanner` hashes bytes, dispatches the bounded project parser, runs + ExifReader as a distinct secondary adapter, and normalizes findings and + coverage. +3. Project parsers walk JPEG segments, PNG chunks, WebP RIFF chunks, TIFF IFDs, + IPTC datasets, and bounded inert XMP text. They validate offsets, lengths, + counts, PNG CRCs, compression expansion, TIFF cycles/depth, and trailing + bytes. They do not follow URLs or instantiate XML/HTML. +4. `sanitize` runs only for complete, static, bounded JPEG/PNG/WebP scans. A + browser decoder produces pixels, the EXIF display orientation is normalized, + and Canvas creates a fresh same-format file. No input container block is + copied. +5. The encoded bytes are passed back through the same independent scanner API, + hashed, dimension-checked, and compared using a deterministic 256-pixel-edge + decoded sample. `buildSanitizationReport` assigns verified/warning/failed + based on explicit coverage and output findings. +6. `archive` serializes bounded deterministic JSON and creates stored ZIP + entries from application-generated `images/` paths and sanitized unique + names. + +Pixel decoding and Canvas encoding currently run on the main browser context +because portable cross-browser image encoder support is there; metadata parsing +and hashing run in the terminable worker. UI state does not retain data after a +page refresh and no IndexedDB/localStorage persistence is used by this app. + +## Trust boundaries + +- Project parsers and ExifReader independently contribute coverage; one parser's + success does not suppress the other's warning. +- Unknown structures are reported or cause partial coverage. Clean-copy + eligibility requires a complete project container scan. +- Browser image decoders, Canvas encoders, Web Crypto, and the JS runtime are in + the trusted computing base. +- ExifReader is pinned to 4.44.0. Dependency updates require malformed-container + regression fixtures and licence review. +- The Toolbox shell receives the application manifest but never receives file + bytes or findings. diff --git a/docs/PRIVACY-SECURITY.md b/docs/PRIVACY-SECURITY.md new file mode 100644 index 0000000..8717d5a --- /dev/null +++ b/docs/PRIVACY-SECURITY.md @@ -0,0 +1,59 @@ +# Privacy and security + +## Data handling + +Files are read with browser file APIs and transferred to an in-page worker. +There is no upload endpoint, account, telemetry, analytics, remote metadata +lookup, or automatic persistence. Temporary object URLs exist only for the +legacy image-element decode fallback and are revoked immediately after decode. +Download object URLs are created and revoked by the shared helper. Refreshing or +closing the page discards application state. + +Service-worker support may fetch and cache the same-origin application shell; +it does not cache imported files, metadata findings, reports, or generated +images. Metadata URLs and XMP/XML markup are inert text and are never fetched or +rendered as HTML. + +## What is inspected + +Every file receives byte-signature inventory and SHA-256. Static JPEG, PNG, and +WebP receive project-owned deep container parsing plus ExifReader. TIFF, +HEIC/HEIF, AVIF, and JPEG XL receive best-effort ExifReader inspection only. +GIF and document/archive formats receive inventory only. Exact per-format +fields are listed in the README support table. + +All parsers are bounded, but a “complete” scan means complete for implemented +structures—not proof that no steganographic or novel carrier exists. Unknown +private chunks and trailing bytes are surfaced. ExifReader failures and format +limitations remain visible in coverage. + +## Re-encoded outputs + +Only complete, static, dimension-bounded JPEG/PNG/WebP project scans are +eligible. The application decodes pixels, normalizes display orientation, and +uses Canvas to encode a new file of the detected type. It does not selectively +strip GPS while copying everything else, because duplicated values can live in +multiple namespaces and embedded previews. It copies no source metadata block. + +The output is always scanned and hashed again. Sensitive or provenance findings, +partial project coverage, or an oriented-dimension mismatch produce a failed +gate. Secondary-parser limitations and provenance invalidation produce explicit +warnings. JPEG and lossy WebP may change pixels; profiles, resolution metadata, +thumbnails, comments, and application history may be lost. PNG is expected to +preserve decoded pixels, subject to browser colour management. + +C2PA/JUMBF carries authenticity/provenance claims. Re-encoding normally removes +or invalidates those claims. The tool reports that effect rather than describing +it as an ordinary privacy win. + +## What this cannot promise + +No result promises anonymity or safe publication. The tool does not remove or +detect visible faces/text/locations, steganography, invisible watermarks, +camera-pattern or image fingerprints, reverse-image matches, sidecar files, +filesystem metadata, clipboard/history records, application caches, backed-up +originals, or cloud/recipient copies. Review the visible output, destination, +report, and surrounding files yourself. + +The JSON report is sensitive by design: it can include original filenames, +hashes, timestamps, and metadata values. Share or retain it only intentionally. diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..54b1935 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,37 @@ +import js from "@eslint/js"; +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; + +export default tseslint.config( + { + ignores: [ + "dist", + "release", + "coverage", + "test-results", + "playwright-report", + ], + }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ["**/*.{ts,tsx}"], + languageOptions: { + ecmaVersion: 2023, + globals: { ...globals.browser, ...globals.worker }, + }, + plugins: { "react-hooks": reactHooks, "react-refresh": reactRefresh }, + rules: { + ...reactHooks.configs.recommended.rules, + "react-refresh/only-export-components": [ + "warn", + { allowConstantExport: true }, + ], + }, + }, + { + files: ["scripts/**/*.mjs", "playwright.config.ts"], + languageOptions: { globals: globals.node }, + }, +); diff --git a/index.html b/index.html new file mode 100644 index 0000000..cf97a7a --- /dev/null +++ b/index.html @@ -0,0 +1,19 @@ + + + + + + + + + + Privacy Tools + + +
+ + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..27acc8e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3524 @@ +{ + "name": "privacy-tools", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "privacy-tools", + "version": "0.1.0", + "license": "GPL-3.0-or-later", + "dependencies": { + "@add-ideas/toolbox-contract": "0.2.3", + "@add-ideas/toolbox-helpers": "0.1.0", + "@add-ideas/toolbox-shell-react": "0.2.3", + "exifreader": "4.44.0", + "fflate": "0.8.2", + "react": "19.2.8", + "react-dom": "19.2.8" + }, + "devDependencies": { + "@add-ideas/toolbox-testkit": "0.2.3", + "@eslint/js": "10.0.1", + "@playwright/test": "1.62.1", + "@testing-library/jest-dom": "6.9.1", + "@testing-library/react": "16.3.2", + "@testing-library/user-event": "14.6.1", + "@types/node": "25.9.5", + "@types/react": "19.2.17", + "@types/react-dom": "19.2.5", + "@vitejs/plugin-react": "6.0.3", + "eslint": "10.7.0", + "eslint-plugin-react-hooks": "7.1.1", + "eslint-plugin-react-refresh": "0.5.2", + "globals": "17.7.0", + "jsdom": "29.1.1", + "prettier": "3.9.5", + "typescript": "6.0.3", + "typescript-eslint": "8.64.0", + "vite": "8.2.2", + "vitest": "4.1.11" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@add-ideas/toolbox-contract": { + "version": "0.2.3", + "license": "Apache-2.0", + "engines": { + "node": ">=20" + } + }, + "node_modules/@add-ideas/toolbox-helpers": { + "version": "0.1.0", + "resolved": "https://git.add-ideas.de/api/packages/lotobo/npm/%40add-ideas%2Ftoolbox-helpers/-/0.1.0/toolbox-helpers-0.1.0.tgz", + "integrity": "sha512-UKl1Oxekedf8D2df86VrnVA53AcMhrnh6iUPXY+k8frirBXotb0yd8SGT+IF/3hcqYwcYe/v9WVFuSgKtIYVnw==", + "license": "GPL-3.0-or-later" + }, + "node_modules/@add-ideas/toolbox-shell-react": { + "version": "0.2.3", + "license": "Apache-2.0", + "dependencies": { + "@add-ideas/toolbox-contract": "0.2.3" + }, + "peerDependencies": { + "react": ">=18 <20", + "react-dom": ">=18 <20" + } + }, + "node_modules/@add-ideas/toolbox-testkit": { + "version": "0.2.3", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@add-ideas/toolbox-contract": "0.2.3" + }, + "bin": { + "toolbox-check": "dist/cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@adobe/css-tools": { + "version": "4.5.0", + "dev": true, + "license": "MIT" + }, + "node_modules/@asamuzakjp/css-color": { + "version": "5.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/generational-cache": "^1.0.1", + "@csstools/css-calc": "^3.2.0", + "@csstools/css-color-parser": "^4.1.0", + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/dom-selector": { + "version": "7.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/generational-cache": "^1.0.1", + "@asamuzakjp/nwsapi": "^2.3.9", + "bidi-js": "^1.0.3", + "css-tree": "^3.2.1", + "is-potential-custom-element-name": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/generational-cache": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/@asamuzakjp/nwsapi": { + "version": "2.3.9", + "dev": true, + "license": "MIT" + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.8", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.8", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bramus/specificity": { + "version": "2.4.2", + "dev": true, + "license": "MIT", + "dependencies": { + "css-tree": "^3.0.0" + }, + "bin": { + "specificity": "bin/cli.js" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "6.1.1", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@csstools/css-calc": { + "version": "3.3.0", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "4.2.2", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^6.1.1", + "@csstools/css-calc": "^3.3.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.0", + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "4.0.0", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^4.0.0" + } + }, + "node_modules/@csstools/css-syntax-patches-for-csstree": { + "version": "1.1.12", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "peerDependencies": { + "css-tree": "^3.2.1" + }, + "peerDependenciesMeta": { + "css-tree": { + "optional": true + } + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "4.0.0", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "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", + "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", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.23.5", + "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.6.0", + "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", + "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", + "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", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.7.2", + "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/@exodus/bytes": { + "version": "1.15.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "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", + "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", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "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", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.147.0", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@playwright/test": { + "version": "1.62.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.62.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.6.tgz", + "integrity": "sha512-b+jTcARdTiFLI6jB4a5XjTm0RWd6KcRfQj/I2356fxUZemiho9zQLxo0RtCuMDAyKcLo6cEltkgbQp6d1+sjjQ==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.6.tgz", + "integrity": "sha512-lkWU8ZJaRk9q3CIEY1Tc7vIFALp3Xw5NfGJo2hQg5oIqNgxWi1zI+IiDEK3r70BF5Dzol1tcXsnzsRc8NLhG+Q==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.6.tgz", + "integrity": "sha512-dgR56NYnvAszm7Ob1B2/Vn0e8bUQYZH2UjVaMMtMVOCKFSfjhfLmuA/9+O+F+ajUdG6B/bSssrKW6JJYASa8jA==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.6.tgz", + "integrity": "sha512-vpVxFvUCFioJqug7OTvqptkc4yb8UX0AwfDmJpaR/0sWz+BUmqSVAf7c8JkUgnN8YLspb4a/N6NhTyMAmdyQ7Q==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.6.tgz", + "integrity": "sha512-h1wG6Y6K3JlRswxsI64qQJqBAy4vrLuHgRbc8CZMGSWTOFRY6ghMApM1NKzB2I0n5xV1fjkE18SuVl2QpLeNpA==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.6.tgz", + "integrity": "sha512-tbCiqub0q2MVWJKgF5PoAlNWCtQydiOYSLIkd8sByqK/6MMYLJRcSXSYodqYtd0O+Fw7QaVmKKlS4oL94YRZ0w==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.6.tgz", + "integrity": "sha512-oxK9+baEBPhZG5HB4URY+uU04zJWeZlH6Tb9rB5DK4DF9XR1uXNLXt5Q5ZsugTKayNCNLhkcwz/ye74hRI98dg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.6.tgz", + "integrity": "sha512-muWCk27FVBEZtv0MsK8gnfSmgczA8KQ0uRVJbTABKhkRfQc38aUrcb7fhi3BNiyseFmgcRsoMfQsSNJ+DbZdSw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.6.tgz", + "integrity": "sha512-eWDoSfU7Co2qj3vgB3Dt4lj1mG6CoWbcJQkRMP3XJplyCMtuaq3LHvPFjS9QIPvMGWVadJC04Xiy0IdcVPtnwQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.6.tgz", + "integrity": "sha512-2bWNjRSIayvupRKxXUY2tWG9fYdoUlTqWywHRvE8Eq3GvuQ+f2HeIkve697fIt+IQs/PV8yFsdWuhp1aJ1PdnA==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.6", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.6.tgz", + "integrity": "sha512-TvtPnfVr+HtyGiDmPK4VWmlNm7QhNNAcK5Q9A7aOXsI8545yCyaoMaicXrFZ72JzeYjaUVk7yT243zT0jzjFKQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.6.tgz", + "integrity": "sha512-iOo0VEay2XFhaCcH0sps5XIimkSuOnNaZrf6+ZkoSOQBJPKNU48RkmJv0/lSpipexu5P+ouFgafe5IGr/DiQfg==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.6.tgz", + "integrity": "sha512-y5NTmmasMS455JlOCO4ZM9krIchv3Mvm1crL1iUPGOPgEzSkves9n0SdC5Sjz6+qWDFhd8/JpfWMH8NSWNHe+A==", + "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.6", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.6.tgz", + "integrity": "sha512-np8iZSLfXlAD4kWhiyq/u0Yt8oZDtRQ8lGhQaCXo2rl37KNjeU0GjJuwr4P3oeZ++ROfofsKNBqR5LTO8aXyWQ==", + "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", + "dev": true, + "license": "MIT" + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/dom": { + "version": "10.4.1", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "picocolors": "1.1.1", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/jest-dom": { + "version": "6.9.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@adobe/css-tools": "^4.4.0", + "aria-query": "^5.0.0", + "css.escape": "^1.5.1", + "dom-accessibility-api": "^0.6.3", + "picocolors": "^1.1.1", + "redent": "^3.0.0" + }, + "engines": { + "node": ">=14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/@testing-library/jest-dom/node_modules/dom-accessibility-api": { + "version": "0.6.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@testing-library/react": { + "version": "16.3.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@testing-library/dom": "^10.0.0", + "@types/react": "^18.0.0 || ^19.0.0", + "@types/react-dom": "^18.0.0 || ^19.0.0", + "react": "^18.0.0 || ^19.0.0", + "react-dom": "^18.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@testing-library/user-event": { + "version": "14.6.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12", + "npm": ">=6" + }, + "peerDependencies": { + "@testing-library/dom": ">=7.21.4" + } + }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/esrecurse": { + "version": "4.3.1", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "25.9.5", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": ">=7.24.0 <7.24.7" + } + }, + "node_modules/@types/react": { + "version": "19.2.17", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.2.5", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.2.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.64.0", + "@typescript-eslint/type-utils": "8.64.0", + "@typescript-eslint/utils": "8.64.0", + "@typescript-eslint/visitor-keys": "8.64.0", + "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.64.0", + "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.8", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.64.0", + "@typescript-eslint/types": "8.64.0", + "@typescript-eslint/typescript-estree": "8.64.0", + "@typescript-eslint/visitor-keys": "8.64.0", + "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.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.64.0", + "@typescript-eslint/types": "^8.64.0", + "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.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.64.0", + "@typescript-eslint/visitor-keys": "8.64.0" + }, + "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.64.0", + "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.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.64.0", + "@typescript-eslint/typescript-estree": "8.64.0", + "@typescript-eslint/utils": "8.64.0", + "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.64.0", + "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.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.64.0", + "@typescript-eslint/tsconfig-utils": "8.64.0", + "@typescript-eslint/types": "8.64.0", + "@typescript-eslint/visitor-keys": "8.64.0", + "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/typescript-estree/node_modules/semver": { + "version": "7.8.5", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.64.0", + "@typescript-eslint/types": "8.64.0", + "@typescript-eslint/typescript-estree": "8.64.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/visitor-keys": { + "version": "8.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.64.0", + "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/@vitejs/plugin-react": { + "version": "6.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0", + "babel-plugin-react-compiler": "^1.0.0", + "vite": "^8.0.0" + }, + "peerDependenciesMeta": { + "@rolldown/plugin-babel": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + } + } + }, + "node_modules/@vitest/expect": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.1.0", + "@types/chai": "^5.2.2", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", + "chai": "^6.2.2", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "4.1.11", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.21" + }, + "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/pretty-format": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "4.1.11", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.11", + "@vitest/utils": "4.1.11", + "magic-string": "^0.30.21", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "4.1.11", + "convert-source-map": "^2.0.0", + "tinyrainbow": "^3.1.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@xmldom/xmldom": { + "version": "0.9.12", + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14.6" + } + }, + "node_modules/acorn": { + "version": "8.18.0", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "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/ansi-regex": { + "version": "5.0.1", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/aria-query": { + "version": "5.3.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "dequal": "^2.0.3" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.20", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/bidi-js": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.9", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/browserslist": { + "version": "4.28.8", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.12", + "caniuse-lite": "^1.0.30001809", + "electron-to-chromium": "^1.5.402", + "node-releases": "^2.0.53", + "update-browserslist-db": "^1.3.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chai": { + "version": "6.2.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/css-tree": { + "version": "3.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/css.escape": { + "version": "1.5.1", + "dev": true, + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.3", + "dev": true, + "license": "MIT" + }, + "node_modules/data-urls": { + "version": "7.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.6.0", + "dev": true, + "license": "MIT" + }, + "node_modules/deep-is": { + "version": "0.1.4", + "dev": true, + "license": "MIT" + }, + "node_modules/dequal": { + "version": "2.0.3", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/electron-to-chromium": { + "version": "1.5.417", + "dev": true, + "license": "ISC" + }, + "node_modules/entities": { + "version": "8.0.0", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "dev": true, + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "10.7.0", + "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.6.0", + "@eslint/core": "^1.2.1", + "@eslint/plugin-kit": "^0.7.2", + "@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": "^8.0.0", + "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.4", + "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-plugin-react-hooks": { + "version": "7.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.24.4", + "@babel/parser": "^7.24.4", + "hermes-parser": "^0.25.1", + "zod": "^3.25.0 || ^4.0.0", + "zod-validation-error": "^3.5.0 || ^4.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0" + } + }, + "node_modules/eslint-plugin-react-refresh": { + "version": "0.5.2", + "dev": true, + "license": "MIT", + "peerDependencies": { + "eslint": "^9 || ^10" + } + }, + "node_modules/eslint-scope": { + "version": "9.1.2", + "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", + "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", + "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", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/exifreader": { + "version": "4.44.0", + "hasInstallScript": true, + "license": "MPL-2.0", + "bin": { + "exifreader": "bin/cli.js" + }, + "optionalDependencies": { + "@xmldom/xmldom": "^0.9.10" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fflate": { + "version": "0.8.2", + "license": "MIT" + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "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": "4.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "dev": true, + "license": "ISC" + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "17.7.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/hermes-estree": { + "version": "0.25.1", + "dev": true, + "license": "MIT" + }, + "node_modules/hermes-parser": { + "version": "0.25.1", + "dev": true, + "license": "MIT", + "dependencies": { + "hermes-estree": "0.25.1" + } + }, + "node_modules/html-encoding-sniffer": { + "version": "6.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.6.0" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/indent-string": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/jsdom": { + "version": "29.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^5.1.11", + "@asamuzakjp/dom-selector": "^7.1.1", + "@bramus/specificity": "^2.4.2", + "@csstools/css-syntax-patches-for-csstree": "^1.1.3", + "@exodus/bytes": "^1.15.0", + "css-tree": "^3.2.1", + "data-urls": "^7.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^6.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.3.5", + "parse5": "^8.0.1", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^6.0.1", + "undici": "^7.25.0", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^16.0.1", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24.0.0" + }, + "peerDependencies": { + "canvas": "^3.0.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/jsdom/node_modules/lru-cache": { + "version": "11.5.2", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/keyv": { + "version": "4.5.4", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "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", + "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, + "libc": [ + "glibc" + ], + "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, + "libc": [ + "musl" + ], + "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", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "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, + "libc": [ + "musl" + ], + "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", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/lz-string": { + "version": "1.5.0", + "dev": true, + "license": "MIT", + "peer": true, + "bin": { + "lz-string": "bin/bin.js" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/mdn-data": { + "version": "2.27.1", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/min-indent": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "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", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.18", + "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", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.54", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/obug": { + "version": "2.1.4", + "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", + "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", + "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", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parse5": { + "version": "8.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^8.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/playwright": { + "version": "1.62.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.62.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.62.1", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/postcss": { + "version": "8.5.26", + "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.17", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.9.5", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/pretty-format": { + "version": "27.5.1", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/react": { + "version": "19.2.8", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.2.8", + "license": "MIT", + "dependencies": { + "scheduler": "^0.27.0" + }, + "peerDependencies": { + "react": "^19.2.8" + } + }, + "node_modules/react-is": { + "version": "17.0.2", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/redent": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rolldown": { + "version": "1.2.6", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.147.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.6", + "@rolldown/binding-android-arm64": "1.2.6", + "@rolldown/binding-darwin-arm64": "1.2.6", + "@rolldown/binding-darwin-x64": "1.2.6", + "@rolldown/binding-freebsd-x64": "1.2.6", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.6", + "@rolldown/binding-linux-arm64-gnu": "1.2.6", + "@rolldown/binding-linux-arm64-musl": "1.2.6", + "@rolldown/binding-linux-ppc64-gnu": "1.2.6", + "@rolldown/binding-linux-s390x-gnu": "1.2.6", + "@rolldown/binding-linux-x64-gnu": "1.2.6", + "@rolldown/binding-linux-x64-musl": "1.2.6", + "@rolldown/binding-openharmony-arm64": "1.2.6", + "@rolldown/binding-win32-arm64-msvc": "1.2.6", + "@rolldown/binding-win32-x64-msvc": "1.2.6" + } + }, + "node_modules/saxes": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/scheduler": { + "version": "0.27.0", + "license": "MIT" + }, + "node_modules/semver": { + "version": "6.3.1", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "4.2.0", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-indent": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "min-indent": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "2.9.0", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "1.3.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "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/tinyrainbow": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tldts": { + "version": "7.4.11", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.4.11" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.4.11", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "6.0.2", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "6.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/type-check": { + "version": "0.4.0", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "6.0.3", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.64.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.64.0", + "@typescript-eslint/parser": "8.64.0", + "@typescript-eslint/typescript-estree": "8.64.0", + "@typescript-eslint/utils": "8.64.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/undici": { + "version": "7.29.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, + "node_modules/undici-types": { + "version": "7.24.6", + "dev": true, + "license": "MIT" + }, + "node_modules/update-browserslist-db": { + "version": "1.3.2", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/vite": { + "version": "8.2.2", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.5", + "postcss": "^8.5.26", + "rolldown": "~1.2.4", + "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.4.0 || ^0.5.0", + "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/vite/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/vitest": { + "version": "4.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.1.11", + "@vitest/mocker": "4.1.11", + "@vitest/pretty-format": "4.1.11", + "@vitest/runner": "4.1.11", + "@vitest/snapshot": "4.1.11", + "@vitest/spy": "4.1.11", + "@vitest/utils": "4.1.11", + "es-module-lexer": "^2.0.0", + "expect-type": "^1.3.0", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "std-env": "^4.0.0-rc.1", + "tinybench": "^2.9.0", + "tinyexec": "^1.0.2", + "tinyglobby": "^0.2.15", + "tinyrainbow": "^3.1.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || >=24.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "4.1.11", + "@vitest/browser-preview": "4.1.11", + "@vitest/browser-webdriverio": "4.1.11", + "@vitest/coverage-istanbul": "4.1.11", + "@vitest/coverage-v8": "4.1.11", + "@vitest/ui": "4.1.11", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.0.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/w3c-xmlserializer": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "16.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.11.0", + "tr46": "^6.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "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": "2.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "dev": true, + "license": "MIT" + }, + "node_modules/yallist": { + "version": "3.1.1", + "dev": true, + "license": "ISC" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zod": { + "version": "4.5.4", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-validation-error": { + "version": "4.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "zod": "^3.25.0 || ^4.0.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f079fe7 --- /dev/null +++ b/package.json @@ -0,0 +1,73 @@ +{ + "name": "privacy-tools", + "version": "0.1.0", + "description": "Inspect and remove shareable-file metadata locally in the browser.", + "license": "GPL-3.0-or-later", + "author": "Albrecht Degering", + "repository": { + "type": "git", + "url": "git+https://git.add-ideas.de/lotobo/privacy-tools.git" + }, + "homepage": "https://git.add-ideas.de/lotobo/privacy-tools", + "bugs": { + "url": "https://git.add-ideas.de/lotobo/privacy-tools/issues" + }, + "private": true, + "type": "module", + "engines": { + "node": ">=22" + }, + "scripts": { + "predev": "npm run manifest:generate", + "dev": "vite", + "prebuild": "npm run release:prepare && npm run manifest:generate", + "build": "tsc -b && vite build", + "preview": "vite preview", + "typecheck": "tsc -b --pretty false", + "lint": "eslint . --max-warnings=0", + "format": "prettier --write .", + "format:check": "prettier --check .", + "test": "vitest run", + "test:watch": "vitest", + "test:browser": "playwright test", + "manifest:generate": "node scripts/generate-toolbox-manifest.mjs", + "manifest:check": "node scripts/generate-toolbox-manifest.mjs --check", + "release:prepare": "node scripts/prepare-release-files.mjs", + "toolbox:check": "toolbox-check dist", + "package:release": "node scripts/package-release.mjs", + "check": "npm run manifest:check && npm run typecheck && npm run lint && npm run format:check && npm run test && npm run build && npm run toolbox:check", + "release:artifact": "npm run check && npm run test:browser && npm run package:release -- --force" + }, + "dependencies": { + "@add-ideas/toolbox-contract": "0.2.3", + "@add-ideas/toolbox-helpers": "0.1.0", + "@add-ideas/toolbox-shell-react": "0.2.3", + "exifreader": "4.44.0", + "fflate": "0.8.2", + "react": "19.2.8", + "react-dom": "19.2.8" + }, + "devDependencies": { + "@add-ideas/toolbox-testkit": "0.2.3", + "@eslint/js": "10.0.1", + "@playwright/test": "1.62.1", + "@testing-library/jest-dom": "6.9.1", + "@testing-library/react": "16.3.2", + "@testing-library/user-event": "14.6.1", + "@types/node": "25.9.5", + "@types/react": "19.2.17", + "@types/react-dom": "19.2.5", + "@vitejs/plugin-react": "6.0.3", + "eslint": "10.7.0", + "eslint-plugin-react-hooks": "7.1.1", + "eslint-plugin-react-refresh": "0.5.2", + "globals": "17.7.0", + "jsdom": "29.1.1", + "prettier": "3.9.5", + "typescript": "6.0.3", + "typescript-eslint": "8.64.0", + "vite": "8.2.2", + "vitest": "4.1.11" + }, + "packageManager": "npm@11.17.0" +} diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..731da62 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,21 @@ +import { defineConfig, devices } from "@playwright/test"; + +export default defineConfig({ + testDir: "./tests/browser", + fullyParallel: false, + workers: 1, + timeout: 120_000, + expect: { timeout: 10_000 }, + reporter: [["list"]], + use: { baseURL: "http://127.0.0.1:4173", trace: "retain-on-failure" }, + webServer: { + command: "npm run build && node scripts/serve-test.mjs", + url: "http://127.0.0.1:4173", + reuseExistingServer: !process.env.CI, + timeout: 180_000, + }, + projects: [ + { name: "chromium", use: { ...devices["Desktop Chrome"] } }, + { name: "firefox", use: { ...devices["Desktop Firefox"] } }, + ], +}); diff --git a/public/CHANGELOG.md b/public/CHANGELOG.md new file mode 100644 index 0000000..e911593 --- /dev/null +++ b/public/CHANGELOG.md @@ -0,0 +1,21 @@ +# Changelog + +## 0.1.0 - 2026-09-01 + +- Added byte-signature inventory, claimed-vs-detected media types, safe names, + SHA-256 hashes, and bounded batches. +- Added project-owned JPEG, PNG, WebP, EXIF/TIFF, IPTC, and XMP scanners with + explicit structural and decompression limits. +- Added ExifReader as a second scanner and best-effort inspect-only coverage for + TIFF, HEIC/HEIF, AVIF, and JPEG XL. +- Added categorized metadata findings, coverage and warning reports, including + selected colour-profile, thumbnail, trailing-data, MPF, JUMBF, and C2PA + indicators. +- Added orientation-normalized pixel re-encoding for supported static JPEG, PNG, + and WebP images, followed by mandatory output hashing, independent re-scan, + dimension/orientation checks, and a bounded pixel-sample comparison. +- Added individual outputs, deterministic JSON reports, bounded batch ZIPs, + cancellation, Toolbox shell integration, offline static packaging, and + explicit no-anonymity boundaries. +- Added generated format/adversarial fixtures, unit gates, and Chromium/Firefox + nested-path and no-network browser gates. diff --git a/public/CONTRIBUTING.md b/public/CONTRIBUTING.md new file mode 100644 index 0000000..1438c5d --- /dev/null +++ b/public/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +Run `npm ci`, `npm run check`, and `npm run test:browser` before proposing a change. Keep processing local, preserve explicit limits, and include fixtures for every parser boundary. diff --git a/public/LICENSE b/public/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/public/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/public/LICENSES/README.md b/public/LICENSES/README.md new file mode 100644 index 0000000..efbd7a1 --- /dev/null +++ b/public/LICENSES/README.md @@ -0,0 +1,3 @@ +# Licences + +The application is GPL-3.0-or-later. Generated release artifacts include an exact runtime dependency licence inventory in `npm-runtime-licenses.txt`. diff --git a/public/LICENSES/npm-runtime-licenses.txt b/public/LICENSES/npm-runtime-licenses.txt new file mode 100644 index 0000000..b143f48 --- /dev/null +++ b/public/LICENSES/npm-runtime-licenses.txt @@ -0,0 +1,1583 @@ +============================================================================== +@add-ideas/toolbox-contract@0.2.3 +Declared licence: Apache-2.0 +============================================================================== +--- LICENSE --- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + Copyright 2026 ADD Ideas + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +============================================================================== +@add-ideas/toolbox-helpers@0.1.0 +Declared licence: GPL-3.0-or-later +============================================================================== +--- LICENSE --- + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + + +============================================================================== +@add-ideas/toolbox-shell-react@0.2.3 +Declared licence: Apache-2.0 +============================================================================== +--- LICENSE --- + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + Copyright 2026 ADD Ideas + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +============================================================================== +@xmldom/xmldom@0.9.12 +Declared licence: MIT +============================================================================== +--- LICENSE --- +Copyright 2019 - present Christopher J. Brody and other contributors, as listed in: https://github.com/xmldom/xmldom/graphs/contributors +Copyright 2012 - 2017 @jindw and other contributors, as listed in: https://github.com/jindw/xmldom/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +============================================================================== +exifreader@4.44.0 +Declared licence: MPL-2.0 +============================================================================== +--- LICENSE --- +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. + + +============================================================================== +fflate@0.8.2 +Declared licence: MIT +============================================================================== +--- LICENSE --- +MIT License + +Copyright (c) 2023 Arjun Barrett + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +============================================================================== +react@19.2.8 +Declared licence: MIT +============================================================================== +--- LICENSE --- +MIT License + +Copyright (c) Meta Platforms, Inc. and affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +react-dom@19.2.8 +Declared licence: MIT +============================================================================== +--- LICENSE --- +MIT License + +Copyright (c) Meta Platforms, Inc. and affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +============================================================================== +scheduler@0.27.0 +Declared licence: MIT +============================================================================== +--- LICENSE --- +MIT License + +Copyright (c) Meta Platforms, Inc. and affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/public/README.md b/public/README.md new file mode 100644 index 0000000..a1c415f --- /dev/null +++ b/public/README.md @@ -0,0 +1,118 @@ +# Privacy Tools + +Privacy Tools is a standalone, local-first browser workbench for inspecting +image metadata and producing deliberately re-encoded sharing copies. It is part +of the [add·ideas Toolbox](https://git.add-ideas.de/lotobo/toolbox-portal), but +the static release also runs independently at any nested path. + +Selected files stay in the browser. There are no accounts, analytics, remote +lookups, telemetry, or runtime network calls. A source file is never modified. + +## Version 0.1 workflow + +1. Select or drop a bounded batch. Every file gets a safe display/download name, + SHA-256 hash, byte-signature type detection, and claimed-vs-detected type + result. +2. Review categorized findings, parser coverage, dimensions, animation or + multi-image status, and warnings. +3. For a supported static JPEG, PNG, or WebP, explicitly re-encode the decoded + pixels. EXIF orientation is normalized; source container blocks, embedded + thumbnails, trailing bytes, and source profiles are not copied. +4. An independently parsed output is mandatory. The result states what was + removed, preserved, generated, unsupported, or incompletely checked, and + includes source/output SHA-256 hashes and a bounded decoded-pixel sample + comparison. +5. Download an individual re-encoded image, a JSON report, or a ZIP containing + re-encoded images and the report. The report itself may be sensitive because + it contains source filenames and metadata values. + +## Format support + +| Format | Inventory | Deep project scan | Secondary scan | Pixel re-encode | +| ------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------ | +| Static JPEG | Yes | EXIF/TIFF, IPTC/Photoshop, XMP, JFIF, ICC, COM, MPF, selected JUMBF/C2PA and trailing bytes | ExifReader | JPEG | +| Static PNG | Yes | tEXt, zTXt, iTXt/XMP, eXIf/TIFF, iCCP, pHYs, tIME, private/unknown ancillary chunks, selected caBX/C2PA and trailing bytes | ExifReader | PNG | +| Static WebP | Yes | RIFF/VP8 dimensions, EXIF/TIFF, XMP, ICC, META, animation and trailing bytes | ExifReader | WebP where the browser encoder supports it | +| TIFF, HEIC/HEIF, AVIF, JPEG XL | Yes | No | Best-effort ExifReader inspection | No | +| GIF | Yes | No | No supported deep adapter | No | +| PDF, ZIP/Office, OLE/legacy Office, unknown | Yes | No | No | No | + +Animation, multi-picture JPEG/MPF, and malformed or partially scanned +JPEG/PNG/WebP inputs are inspect-only. Secondary coverage depends on what +ExifReader can establish for the particular container. A browser may decode a +format it cannot encode; that still does not make it eligible for output. + +Findings are grouped as location; people/authorship/rights; dates; device, +serial and lens; software/history; document identifiers; comments/titles/ +keywords; embedded previews; colour profiles; provenance; technical; or +unclassified. Raw XMP is shown only as bounded inert text—never injected as +markup. + +## Security boundaries and limits + +Inputs are untrusted. Container parsing runs in a terminable worker and checks +declared lengths, CRCs, offsets, TIFF cycles/depth/counts, chunk/segment counts, +compressed metadata expansion, dimensions, and aggregate batch size before +continuing. Defaults are 100 files, 128 MiB per file, 512 MiB per batch, 4,096 +metadata blocks/findings, 8 MiB per metadata block, 4 MiB decompressed metadata, +512-character labels, 16,384-character values, 256 KiB normalized finding text +per file, 40 megapixels, a 32,768-pixel edge, and a 256 MiB ZIP payload. + +The pixel decode/encode step uses browser-native image and Canvas APIs. It runs +only after a complete project scan and bounded dimensions. The output gate does +not trust successful encoding: it hashes and scans the newly encoded bytes +again. C2PA/JUMBF provenance is authenticity information rather than ordinary +tracking metadata; pixel re-encoding removes or invalidates it, and the report +calls that out. + +This is not an anonymity tool. Metadata removal does not remove visible faces +or text, steganography, invisible or forensic watermarks, reverse-image +matching, sidecar files, filesystem history, application caches, or cloud and +recipient copies. JPEG and lossy WebP output may alter pixels. Colour profiles, +resolution metadata, and provenance may be lost. Inspect the actual output and +report before sharing it. + +See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) and +[docs/PRIVACY-SECURITY.md](docs/PRIVACY-SECURITY.md) for the implementation and +threat model. + +## Browser and accessibility support + +Current evergreen Chromium and Firefox are exercised in the browser gate; +current Safari is an intended target. JavaScript modules, Web Workers, Blob, +Canvas 2D, `createImageBitmap` where available, and Web Crypto are used. WebP +output follows browser encoder support. The application supports the shared +Toolbox system/light/dark themes, keyboard file selection, native table and +disclosure semantics, visible focus, live progress, and non-colour status text. + +## Development + +Requirements: Node.js 22 or newer and npm 11 or newer. + +```sh +npm ci +npm run check +npm run test:browser +npm run dev +``` + +Vite uses `base: './'`, so `dist/` can be hosted at `/` or below a nested +Toolbox path. `toolbox-check` validates the production manifest and bundle. + +## Release + +```sh +npm run release:artifact +``` + +This checks the manifest, types, lint, formatting, unit fixtures, production +build, Toolbox contract, and Chromium/Firefox workflows, then creates the +deterministic `release/privacy-tools-0.1.0.zip` plus its SHA-256 sidecar. The +archive contains the static application, project documents, and exact runtime +dependency licence texts. + +## Licence + +Privacy Tools is free software under `GPL-3.0-or-later`; see [LICENSE](LICENSE). +Runtime dependencies keep their licences, including ExifReader under MPL-2.0. +See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). diff --git a/public/SECURITY.md b/public/SECURITY.md new file mode 100644 index 0000000..63624f0 --- /dev/null +++ b/public/SECURITY.md @@ -0,0 +1,33 @@ +# Security + +Report vulnerabilities privately to the repository owner. Do not attach a +sensitive source image, generated report, or real metadata to a public issue; +construct a minimal synthetic reproduction instead. + +## Input model + +Every selected file and every metadata value is untrusted. The application +detects containers from bytes, does not execute imported content, renders text +through React rather than raw HTML, performs no metadata-linked fetches, and +does not preserve source blocks in a re-encoded output. The scanning worker can +be terminated on cancellation. Browser-native pixel decoding remains part of +the browser's trusted computing base. + +Default bounds cover file/batch bytes, container blocks, individual metadata, +decompressed PNG metadata, finding lengths/counts, TIFF offsets/entries/depth, +pixel count/edge, and batch ZIP size. Malformed structures become partial or +failed coverage; they must never receive clean-copy eligibility or a verified +output result. + +## Output model + +A successful Canvas encode is not sufficient. The new bytes are independently +hashed and scanned, expected oriented dimensions are checked, sensitive or +provenance findings fail the verification gate, and incomplete coverage is +reported. C2PA/JUMBF signatures are expected to be removed or invalidated by +pixel re-encoding. Reports and output names are escaped/sanitized and ZIP paths +are application-generated. + +No status is an anonymity guarantee. Visible content, steganography, invisible +watermarks, image fingerprinting, sidecars, local filesystem metadata, browser +history, and remote copies are outside the scan. diff --git a/public/SOURCE.md b/public/SOURCE.md new file mode 100644 index 0000000..618fc8c --- /dev/null +++ b/public/SOURCE.md @@ -0,0 +1,23 @@ +# Corresponding source + +The corresponding source for Privacy Tools 0.1.0 is published at: + +https://git.add-ideas.de/lotobo/privacy-tools/src/tag/v0.1.0 + +Build with Node.js 22 and npm 11: + +```sh +npm ci +npm run release:artifact +``` + +The release command performs all source, test, browser, manifest, and Toolbox +checks before assembling the deterministic static ZIP. The artifact includes +this file, the GPL licence, project documentation, and the runtime dependency +licence texts generated from the exact lockfile. + +ExifReader 4.44.0 is unmodified MPL-2.0 covered software within the bundled +application. Its preferred source form is available from the exact npm package +and upstream release identified in `package-lock.json` and +`THIRD_PARTY_NOTICES.md`; its MPL licence text is included in the generated +runtime licence inventory. diff --git a/public/THIRD_PARTY_NOTICES.md b/public/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..ef8a284 --- /dev/null +++ b/public/THIRD_PARTY_NOTICES.md @@ -0,0 +1,23 @@ +# Third-party notices + +Privacy Tools is GPL-3.0-or-later. Dependencies retain their own licences. A +production build generates `LICENSES/npm-runtime-licenses.txt` from the exact +locked runtime packages and copies every available licence/notice text into the +release. + +Material runtime components include: + +| Component | Version | Licence | Purpose/source | +| -------------------------------- | ------- | ---------------- | -------------------------------------------------------------------------------------------------- | +| ExifReader | 4.44.0 | MPL-2.0 | Secondary metadata parser; | +| fflate | 0.8.2 | MIT | Bounded PNG metadata inflation and ZIP creation; | +| `@add-ideas/toolbox-helpers` | 0.1.0 | GPL-3.0-or-later | Hashing, safe names, download and deterministic JSON primitives | +| `@add-ideas/toolbox-contract` | 0.2.3 | Apache-2.0 | Toolbox manifest contract | +| `@add-ideas/toolbox-shell-react` | 0.2.3 | Apache-2.0 | Shared application shell | +| React / React DOM | 19.2.8 | MIT | User interface | + +ExifReader is used unmodified. Its MPL-2.0 covered source remains available at +the exact upstream link above and through the npm package resolved by the +lockfile. The bundled executable does not relicense or restrict the MPL-covered +files. Consult the generated licence inventory for the full MPL-2.0 text and +the exact notices shipped with every runtime package. diff --git a/public/docs/ACCESSIBILITY.md b/public/docs/ACCESSIBILITY.md new file mode 100644 index 0000000..f1afd0e --- /dev/null +++ b/public/docs/ACCESSIBILITY.md @@ -0,0 +1,16 @@ +# Accessibility + +The workbench uses semantic landmarks, headings, a native multiple-file input, +buttons, tables, definition lists, progress, status/alert regions, and native +disclosures/dialogs. All workflows are keyboard operable; drop is an optional +pointer shortcut. Visible focus and the shared Toolbox system/light/dark themes +are preserved. + +Status is always written as text and never encoded by colour alone. Finding +categories expose labels and counts, hashes and media types remain selectable, +and responsive layouts allow horizontal table scrolling without clipping the +whole page. Motion is not required to understand progress or results. + +Automated component and Chromium/Firefox browser gates cover semantics and core +workflows. They supplement, rather than replace, manual keyboard, zoom, +screen-reader, high-contrast, and reduced-motion review before release. diff --git a/public/docs/ARCHITECTURE.md b/public/docs/ARCHITECTURE.md new file mode 100644 index 0000000..8affc35 --- /dev/null +++ b/public/docs/ARCHITECTURE.md @@ -0,0 +1,49 @@ +# Architecture + +Privacy Tools is a relocatable Vite/React static application. The core domain +model in `src/privacy` is serializable: scan inputs cross a worker boundary as +transferred `ArrayBuffer`s and results contain only strings, numbers, booleans, +arrays, and plain objects. No parser returns HTML or a live third-party object. + +## Pipeline + +1. `scan-client` checks file count and declared byte totals before reading the + batch, transfers buffers to a dedicated worker, reports progress, and + terminates the worker on cancellation. +2. `detect` compares magic bytes, filename extension, and browser-claimed MIME. + `scanner` hashes bytes, dispatches the bounded project parser, runs + ExifReader as a distinct secondary adapter, and normalizes findings and + coverage. +3. Project parsers walk JPEG segments, PNG chunks, WebP RIFF chunks, TIFF IFDs, + IPTC datasets, and bounded inert XMP text. They validate offsets, lengths, + counts, PNG CRCs, compression expansion, TIFF cycles/depth, and trailing + bytes. They do not follow URLs or instantiate XML/HTML. +4. `sanitize` runs only for complete, static, bounded JPEG/PNG/WebP scans. A + browser decoder produces pixels, the EXIF display orientation is normalized, + and Canvas creates a fresh same-format file. No input container block is + copied. +5. The encoded bytes are passed back through the same independent scanner API, + hashed, dimension-checked, and compared using a deterministic 256-pixel-edge + decoded sample. `buildSanitizationReport` assigns verified/warning/failed + based on explicit coverage and output findings. +6. `archive` serializes bounded deterministic JSON and creates stored ZIP + entries from application-generated `images/` paths and sanitized unique + names. + +Pixel decoding and Canvas encoding currently run on the main browser context +because portable cross-browser image encoder support is there; metadata parsing +and hashing run in the terminable worker. UI state does not retain data after a +page refresh and no IndexedDB/localStorage persistence is used by this app. + +## Trust boundaries + +- Project parsers and ExifReader independently contribute coverage; one parser's + success does not suppress the other's warning. +- Unknown structures are reported or cause partial coverage. Clean-copy + eligibility requires a complete project container scan. +- Browser image decoders, Canvas encoders, Web Crypto, and the JS runtime are in + the trusted computing base. +- ExifReader is pinned to 4.44.0. Dependency updates require malformed-container + regression fixtures and licence review. +- The Toolbox shell receives the application manifest but never receives file + bytes or findings. diff --git a/public/docs/PRIVACY-SECURITY.md b/public/docs/PRIVACY-SECURITY.md new file mode 100644 index 0000000..8717d5a --- /dev/null +++ b/public/docs/PRIVACY-SECURITY.md @@ -0,0 +1,59 @@ +# Privacy and security + +## Data handling + +Files are read with browser file APIs and transferred to an in-page worker. +There is no upload endpoint, account, telemetry, analytics, remote metadata +lookup, or automatic persistence. Temporary object URLs exist only for the +legacy image-element decode fallback and are revoked immediately after decode. +Download object URLs are created and revoked by the shared helper. Refreshing or +closing the page discards application state. + +Service-worker support may fetch and cache the same-origin application shell; +it does not cache imported files, metadata findings, reports, or generated +images. Metadata URLs and XMP/XML markup are inert text and are never fetched or +rendered as HTML. + +## What is inspected + +Every file receives byte-signature inventory and SHA-256. Static JPEG, PNG, and +WebP receive project-owned deep container parsing plus ExifReader. TIFF, +HEIC/HEIF, AVIF, and JPEG XL receive best-effort ExifReader inspection only. +GIF and document/archive formats receive inventory only. Exact per-format +fields are listed in the README support table. + +All parsers are bounded, but a “complete” scan means complete for implemented +structures—not proof that no steganographic or novel carrier exists. Unknown +private chunks and trailing bytes are surfaced. ExifReader failures and format +limitations remain visible in coverage. + +## Re-encoded outputs + +Only complete, static, dimension-bounded JPEG/PNG/WebP project scans are +eligible. The application decodes pixels, normalizes display orientation, and +uses Canvas to encode a new file of the detected type. It does not selectively +strip GPS while copying everything else, because duplicated values can live in +multiple namespaces and embedded previews. It copies no source metadata block. + +The output is always scanned and hashed again. Sensitive or provenance findings, +partial project coverage, or an oriented-dimension mismatch produce a failed +gate. Secondary-parser limitations and provenance invalidation produce explicit +warnings. JPEG and lossy WebP may change pixels; profiles, resolution metadata, +thumbnails, comments, and application history may be lost. PNG is expected to +preserve decoded pixels, subject to browser colour management. + +C2PA/JUMBF carries authenticity/provenance claims. Re-encoding normally removes +or invalidates those claims. The tool reports that effect rather than describing +it as an ordinary privacy win. + +## What this cannot promise + +No result promises anonymity or safe publication. The tool does not remove or +detect visible faces/text/locations, steganography, invisible watermarks, +camera-pattern or image fingerprints, reverse-image matches, sidecar files, +filesystem metadata, clipboard/history records, application caches, backed-up +originals, or cloud/recipient copies. Review the visible output, destination, +report, and surrounding files yourself. + +The JSON report is sensitive by design: it can include original filenames, +hashes, timestamps, and metadata values. Share or retain it only intentionally. diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..4c98aab --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1 @@ +PR diff --git a/public/manifest.webmanifest b/public/manifest.webmanifest new file mode 100644 index 0000000..82fc41c --- /dev/null +++ b/public/manifest.webmanifest @@ -0,0 +1,18 @@ +{ + "name": "Privacy Tools", + "short_name": "Privacy", + "description": "Inspect and remove shareable-file metadata locally in the browser.", + "start_url": "./", + "scope": "./", + "display": "standalone", + "background_color": "#f6f7fb", + "theme_color": "#29255f", + "icons": [ + { + "src": "./favicon.svg", + "sizes": "any", + "type": "image/svg+xml", + "purpose": "any maskable" + } + ] +} diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..ea09921 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,54 @@ +const CACHE_PREFIX = "privacy-tools-shell-"; +const CACHE_NAME = CACHE_PREFIX + "0.1.0"; +const CORE = ["./", "./manifest.webmanifest", "./favicon.svg"]; +self.addEventListener("install", (event) => { + event.waitUntil( + caches.open(CACHE_NAME).then(async (cache) => { + await cache.addAll(CORE); + const html = await (await fetch("./")).text(); + const assets = [...html.matchAll(/(?:src|href)="(\.\/assets\/[^"]+)"/g)] + .map((match) => match[1]) + .filter(Boolean); + await cache.addAll(assets); + }), + ); + self.skipWaiting(); +}); +self.addEventListener("activate", (event) => { + event.waitUntil( + caches + .keys() + .then((keys) => + Promise.all( + keys + .filter((key) => key.startsWith(CACHE_PREFIX) && key !== CACHE_NAME) + .map((key) => caches.delete(key)), + ), + ) + .then(() => self.clients.claim()), + ); +}); +self.addEventListener("fetch", (event) => { + if (event.request.method !== "GET") return; + const url = new URL(event.request.url); + if ( + url.origin !== self.location.origin || + !url.pathname.startsWith(new URL(self.registration.scope).pathname) + ) + return; + event.respondWith( + caches.match(event.request).then( + (cached) => + cached ?? + fetch(event.request).then((response) => { + if (response.ok) { + const copy = response.clone(); + void caches + .open(CACHE_NAME) + .then((cache) => cache.put(event.request, copy)); + } + return response; + }), + ), + ); +}); diff --git a/public/toolbox-app.json b/public/toolbox-app.json new file mode 100644 index 0000000..4236046 --- /dev/null +++ b/public/toolbox-app.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://git.add-ideas.de/lotobo/toolbox-sdk/raw/branch/main/schemas/toolbox-app.v1.schema.json", + "schemaVersion": 1, + "id": "de.add-ideas.privacy-tools", + "name": "Privacy Tools", + "version": "0.1.0", + "description": "Inspect and remove shareable-file metadata locally in the browser.", + "entry": "./", + "icon": "./favicon.svg", + "categories": ["privacy", "files", "security"], + "tags": ["metadata", "exif", "privacy", "sanitize", "share"], + "integration": { + "contextVersion": 1, + "launchModes": ["navigate", "new-tab"], + "embedding": "unsupported" + }, + "requirements": { + "secureContext": true, + "workers": true, + "indexedDb": false, + "crossOriginIsolated": false, + "topLevelContext": false + }, + "privacy": { + "processing": "local", + "fileUploads": true, + "telemetry": false, + "label": "Inputs stay in this browser; nothing is uploaded." + }, + "source": { + "repository": "https://git.add-ideas.de/lotobo/privacy-tools", + "license": "GPL-3.0-or-later" + }, + "actions": [ + { + "id": "source", + "label": "Source", + "url": "https://git.add-ideas.de/lotobo/privacy-tools" + } + ] +} diff --git a/scripts/generate-toolbox-manifest.mjs b/scripts/generate-toolbox-manifest.mjs new file mode 100644 index 0000000..3861261 --- /dev/null +++ b/scripts/generate-toolbox-manifest.mjs @@ -0,0 +1,33 @@ +import { readFile, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { format } from "prettier"; +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const sourcePath = path.join(root, "src/toolbox/manifest.source.json"); +const outputPath = path.join(root, "public/toolbox-app.json"); +const source = JSON.parse(await readFile(sourcePath, "utf8")); +const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8")); +const versionSource = await readFile(path.join(root, "src/version.ts"), "utf8"); +const appVersion = /^export const APP_VERSION = "([^"]+)";$/mu.exec( + versionSource, +)?.[1]; +const repository = "https://git.add-ideas.de/lotobo/" + pkg.name; +if (source.version !== pkg.version || appVersion !== pkg.version) + throw new Error("Version identity drift"); +if ( + source.id !== "de.add-ideas." + pkg.name || + source.source?.repository !== repository || + source.source?.license !== "GPL-3.0-or-later" +) + throw new Error("Manifest source identity is invalid"); +const serialized = await format(JSON.stringify(source), { + filepath: outputPath, +}); +if (process.argv.includes("--check")) { + if ((await readFile(outputPath, "utf8").catch(() => "")) !== serialized) + throw new Error("public/toolbox-app.json is stale"); + console.log("Toolbox manifest is synchronized"); +} else { + await writeFile(outputPath, serialized); + console.log("Generated public/toolbox-app.json"); +} diff --git a/scripts/package-release.mjs b/scripts/package-release.mjs new file mode 100644 index 0000000..1629f25 --- /dev/null +++ b/scripts/package-release.mjs @@ -0,0 +1,165 @@ +#!/usr/bin/env node +import { createHash } from "node:crypto"; +import { execFile } from "node:child_process"; +import { + access, + chmod, + copyFile, + cp, + lstat, + mkdir, + mkdtemp, + readFile, + readdir, + rename, + rm, + utimes, + writeFile, +} from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import { promisify } from "node:util"; +import { fileURLToPath } from "node:url"; +const execute = promisify(execFile); +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8")); +const argument = (name, fallback) => { + const index = process.argv.indexOf(name); + return index >= 0 ? process.argv[index + 1] : fallback; +}; +const output = path.resolve( + root, + argument("--output", "release/" + pkg.name + "-" + pkg.version + ".zip"), +); +const checksumOutput = output + ".sha256"; +const force = process.argv.includes("--force"); +if ( + path.extname(output).toLowerCase() !== ".zip" || + output === root || + output === path.parse(output).root +) + throw new Error("Unsafe release target"); +const exists = (file) => + access(file).then( + () => true, + () => false, + ); +if (!force && ((await exists(output)) || (await exists(checksumOutput)))) + throw new Error("Release output exists"); +const input = path.join(root, "dist"); +for (const name of [ + "index.html", + "manifest.webmanifest", + "sw.js", + "toolbox-app.json", + "favicon.svg", + "README.md", + "CHANGELOG.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "SOURCE.md", + "THIRD_PARTY_NOTICES.md", + "LICENSES/README.md", + "LICENSES/npm-runtime-licenses.txt", + "docs/ACCESSIBILITY.md", + "docs/ARCHITECTURE.md", + "docs/PRIVACY-SECURITY.md", +]) { + const details = await lstat(path.join(input, name)).catch(() => null); + if (!details?.isFile() || details.isSymbolicLink()) + throw new Error("Missing release file: " + name); +} +const manifest = JSON.parse( + await readFile(path.join(input, "toolbox-app.json"), "utf8"), +); +const repository = "https://git.add-ideas.de/lotobo/" + pkg.name; +if ( + manifest.id !== "de.add-ideas." + pkg.name || + manifest.version !== pkg.version || + manifest.entry !== "./" || + manifest.icon !== "./favicon.svg" || + manifest.source?.repository !== repository +) + throw new Error("Packaged manifest identity is invalid"); +if ( + /\b(?:src|href)=["']\//iu.test( + await readFile(path.join(input, "index.html"), "utf8"), + ) +) + throw new Error("Root-absolute asset reference"); +async function collect(directory, prefix = "") { + const files = []; + for (const entry of (await readdir(directory, { withFileTypes: true })).sort( + (a, b) => a.name.localeCompare(b.name), + )) { + const absolute = path.join(directory, entry.name); + const relative = prefix ? prefix + "/" + entry.name : entry.name; + if (entry.isSymbolicLink()) + throw new Error("Symlink in release: " + relative); + if (entry.isDirectory()) files.push(...(await collect(absolute, relative))); + else if (entry.isFile()) files.push({ absolute, relative }); + else throw new Error("Unsupported release entry: " + relative); + } + return files; +} +const sourceFiles = await collect(input); +for (const file of sourceFiles) + if ( + file.relative.endsWith(".map") || + /(?:^|\/)(?:\.env(?:\.|$)|id_rsa|id_ed25519|.*\.pem$|.*\.key$)/iu.test( + file.relative, + ) || + file.relative.split("/").includes("..") + ) + throw new Error("Forbidden release entry: " + file.relative); +await mkdir(path.dirname(output), { recursive: true }); +const stagingRoot = await mkdtemp( + path.join(os.tmpdir(), pkg.name + "-release-"), +); +const publicationRoot = await mkdtemp( + path.join(path.dirname(output), "." + pkg.name + "-publish-"), +); +const stagedTree = path.join(stagingRoot, "tree"); +const stagedArchive = path.join(stagingRoot, path.basename(output)); +try { + await cp(input, stagedTree, { recursive: true }); + const timestamp = new Date("1980-01-01T00:00:00.000Z"); + for (const file of await collect(stagedTree)) { + await chmod(file.absolute, 0o644); + await utimes(file.absolute, timestamp, timestamp); + } + await execute( + "zip", + [ + "-X", + "-q", + "-9", + stagedArchive, + ...sourceFiles.map((file) => file.relative), + ], + { + cwd: stagedTree, + env: { ...process.env, TZ: "UTC" }, + maxBuffer: 1024 * 1024, + }, + ); + const archive = await readFile(stagedArchive); + const digest = createHash("sha256").update(archive).digest("hex"); + const stagedChecksum = stagedArchive + ".sha256"; + await writeFile(stagedChecksum, digest + " " + path.basename(output) + "\n"); + const publicationArchive = path.join(publicationRoot, path.basename(output)); + const publicationChecksum = publicationArchive + ".sha256"; + await copyFile(stagedArchive, publicationArchive); + await copyFile(stagedChecksum, publicationChecksum); + if (force) { + await rm(output, { force: true }); + await rm(checksumOutput, { force: true }); + } + await rename(publicationArchive, output); + await rename(publicationChecksum, checksumOutput); + console.log("Created " + path.relative(root, output) + "\nSHA-256 " + digest); +} finally { + await rm(stagingRoot, { recursive: true, force: true }); + await rm(publicationRoot, { recursive: true, force: true }); +} diff --git a/scripts/prepare-release-files.mjs b/scripts/prepare-release-files.mjs new file mode 100644 index 0000000..e5d09e9 --- /dev/null +++ b/scripts/prepare-release-files.mjs @@ -0,0 +1,70 @@ +import { cp, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); +const destination = path.join(root, "public"); +for (const name of [ + "LICENSE", + "README.md", + "CHANGELOG.md", + "CONTRIBUTING.md", + "SECURITY.md", + "SOURCE.md", + "THIRD_PARTY_NOTICES.md", +]) { + await readFile(path.join(root, name)); + await cp(path.join(root, name), path.join(destination, name)); +} +for (const directory of ["LICENSES", "docs"]) { + const output = path.join(destination, directory); + await rm(output, { recursive: true, force: true }); + await cp(path.join(root, directory), output, { recursive: true }); +} +const lock = JSON.parse( + await readFile(path.join(root, "package-lock.json"), "utf8"), +); +const sections = []; +for (const [location, locked] of Object.entries(lock.packages ?? {}).sort( + ([a], [b]) => a.localeCompare(b), +)) { + if (!location.includes("node_modules/") || locked.dev === true) continue; + const packageDirectory = path.join(root, location); + const details = JSON.parse( + await readFile(path.join(packageDirectory, "package.json"), "utf8"), + ); + const candidates = (await readdir(packageDirectory)) + .filter((name) => /^(?:licen[cs]e|copying|notice)(?:\.|$)/iu.test(name)) + .sort(); + const texts = []; + for (const candidate of candidates) { + try { + texts.push( + "--- " + + candidate + + " ---\n" + + (await readFile(path.join(packageDirectory, candidate), "utf8")), + ); + } catch { + /* directory */ + } + } + sections.push( + "=".repeat(78) + + "\n" + + details.name + + "@" + + details.version + + "\nDeclared licence: " + + (details.license ?? locked.license ?? "See upstream") + + "\n" + + "=".repeat(78) + + "\n" + + (texts.join("\n\n") || "See upstream package metadata."), + ); +} +await mkdir(path.join(destination, "LICENSES"), { recursive: true }); +await writeFile( + path.join(destination, "LICENSES/npm-runtime-licenses.txt"), + sections.join("\n\n").trimEnd() + "\n", +); +console.log("Prepared release documentation"); diff --git a/scripts/serve-test.mjs b/scripts/serve-test.mjs new file mode 100644 index 0000000..f131fb0 --- /dev/null +++ b/scripts/serve-test.mjs @@ -0,0 +1,66 @@ +import { createServer } from "node:http"; +import { readFile, stat } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +const root = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + "..", + "dist", +); +const prefix = "/deep/nested/privacy/"; +const types = new Map([ + [".css", "text/css; charset=utf-8"], + [".html", "text/html; charset=utf-8"], + [".js", "text/javascript; charset=utf-8"], + [".json", "application/json; charset=utf-8"], + [".webmanifest", "application/manifest+json; charset=utf-8"], + [".svg", "image/svg+xml"], + [".md", "text/markdown; charset=utf-8"], + [".txt", "text/plain; charset=utf-8"], + [".wasm", "application/wasm"], + [".png", "image/png"], + [".jpg", "image/jpeg"], + [".webp", "image/webp"], +]); +const headers = { + "Content-Security-Policy": + "default-src 'self'; base-uri 'self'; object-src 'none'; frame-ancestors 'none'; form-action 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; media-src 'self' blob:; connect-src 'self'; worker-src 'self' blob:; manifest-src 'self'", + "Cross-Origin-Opener-Policy": "same-origin", + "Cross-Origin-Resource-Policy": "same-origin", + "Permissions-Policy": + "camera=(), microphone=(), geolocation=(), usb=(), payment=()", + "Referrer-Policy": "no-referrer", + "X-Content-Type-Options": "nosniff", +}; +const server = createServer(async (request, response) => { + try { + const url = new URL(request.url ?? "/", "http://127.0.0.1"); + const relative = decodeURIComponent(url.pathname).startsWith(prefix) + ? decodeURIComponent(url.pathname).slice(prefix.length) + : decodeURIComponent(url.pathname).replace(/^\/+/, ""); + const normalized = path.posix.normalize(relative || "index.html"); + if ( + normalized === ".." || + normalized.startsWith("../") || + path.isAbsolute(normalized) + ) { + response.writeHead(400).end("Bad request"); + return; + } + let file = path.join(root, normalized); + if ((await stat(file).catch(() => null))?.isDirectory()) + file = path.join(file, "index.html"); + const content = await readFile(file); + response.writeHead(200, { + "Content-Type": + types.get(path.extname(file)) ?? "application/octet-stream", + "Cache-Control": "no-cache", + ...headers, + }); + response.end(content); + } catch { + response.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" }); + response.end("Not found"); + } +}); +server.listen(4173, "127.0.0.1", () => console.log("Test server ready")); diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..7d842ea --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,35 @@ +import { lazy, Suspense, useState } from "react"; +import { AppShell } from "@add-ideas/toolbox-shell-react"; +import "@add-ideas/toolbox-shell-react/styles.css"; +import "./styles.css"; +import { ErrorBoundary } from "./components/ErrorBoundary"; +import { HelpDialog } from "./components/HelpDialog"; +import { manifest } from "./toolbox/manifest"; + +const Workbench = lazy(async () => ({ + default: (await import("./components/Workbench")).Workbench, +})); + +export function App() { + const [helpOpen, setHelpOpen] = useState(false); + return ( + + setHelpOpen(true) }} + > + + Preparing Privacy Tools… +

+ } + > + +
+
+ setHelpOpen(false)} /> +
+ ); +} diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx new file mode 100644 index 0000000..8f8623a --- /dev/null +++ b/src/components/ErrorBoundary.tsx @@ -0,0 +1,27 @@ +import { Component, type ErrorInfo, type ReactNode } from "react"; + +export class ErrorBoundary extends Component< + { children: ReactNode }, + { error?: Error } +> { + state: { error?: Error } = {}; + static getDerivedStateFromError(error: Error) { + return { error }; + } + componentDidCatch(error: Error, info: ErrorInfo) { + console.error("Application failure", error, info); + } + render() { + if (this.state.error) + return ( +
+

Privacy Tools could not continue

+

{this.state.error.message}

+ +
+ ); + return this.props.children; + } +} diff --git a/src/components/HelpDialog.tsx b/src/components/HelpDialog.tsx new file mode 100644 index 0000000..056730a --- /dev/null +++ b/src/components/HelpDialog.tsx @@ -0,0 +1,77 @@ +import { useEffect, useRef } from "react"; + +export function HelpDialog({ + open, + onClose, +}: { + open: boolean; + onClose(): void; +}) { + const dialog = useRef(null); + useEffect(() => { + const node = dialog.current; + if (!node) return; + if (open && !node.open) node.showModal(); + if (!open && node.open) node.close(); + }, [open]); + return ( + { + event.preventDefault(); + onClose(); + }} + aria-labelledby="help-title" + > +
+
+

Local-first help

+

About Privacy Tools

+
+ +
+
+
+

What inspection covers

+

+ All files receive magic-byte inventory. JPEG, PNG and WebP receive + bounded container scans for EXIF, IPTC, XMP, text, profiles, + thumbnails and selected provenance blocks. A separate ExifReader + pass expands coverage and inspects TIFF, HEIC, AVIF and JXL on a + best-effort basis. GIF and document formats receive inventory only. +

+
+
+

What a clean copy means

+

+ Supported static images are decoded to pixels, displayed orientation + is normalized, and a new JPEG, PNG or WebP is encoded. No source + metadata block is copied. The output must pass both scanners before + it can receive a verified result. +

+
+
+

Important limits

+

+ Animation and multi-image files are inspect-only. Re-encoding may + change JPEG/WebP pixels, colour profiles, resolution metadata and + file size. C2PA/JUMBF provenance is removed or invalidated and is + never silently described as preserved. +

+
+
+

No anonymity promise

+

+ Visible content, steganography, invisible watermarks, reverse-image + matching, sidecars, filesystem history and remote copies remain + outside this tool. Review the actual image before sharing it. +

+
+
+
+ ); +} diff --git a/src/components/Workbench.tsx b/src/components/Workbench.tsx new file mode 100644 index 0000000..6677894 --- /dev/null +++ b/src/components/Workbench.tsx @@ -0,0 +1,687 @@ +import { useEffect, useMemo, useRef, useState } from "react"; +import { triggerBlobDownload } from "@add-ideas/toolbox-helpers"; + +import { + createBatchArchive, + createBatchReport, + sanitizeStaticImage, + scanFilesInWorker, + serializeReport, + type FindingCategory, + type ImageScanResult, + type SanitizedAsset, +} from "../privacy"; + +interface FileRecord { + file: File; + scan: ImageScanResult; + asset?: SanitizedAsset; + sanitizing?: boolean; + error?: string; +} + +interface Progress { + completed: number; + total: number; + currentName: string; +} + +const CATEGORY_LABELS: Readonly> = + Object.freeze({ + location: "Location", + identity: "People, authorship & rights", + timestamp: "Dates & times", + device: "Device, serial & lens", + software: "Software & history", + "document-id": "Document identifiers", + comment: "Comments, titles & keywords", + thumbnail: "Embedded previews & extra images", + "colour-profile": "Colour profiles", + provenance: "Provenance & signatures", + technical: "Technical metadata", + unknown: "Unclassified metadata", + }); + +export function Workbench() { + const [records, setRecords] = useState([]); + const [busy, setBusy] = useState<"scan" | "sanitize" | "archive" | null>( + null, + ); + const [progress, setProgress] = useState(null); + const [error, setError] = useState(""); + const [dragging, setDragging] = useState(false); + const abortRef = useRef(null); + const inputRef = useRef(null); + const cleanable = useMemo( + () => records.filter((record) => record.scan.cleanable), + [records], + ); + const assets = useMemo( + () => records.flatMap((record) => (record.asset ? [record.asset] : [])), + [records], + ); + + useEffect( + () => () => { + abortRef.current?.abort(); + }, + [], + ); + + const importFiles = async (selection: FileList | readonly File[]) => { + const files = Array.from(selection); + if (files.length === 0) return; + abortRef.current?.abort(); + const controller = new AbortController(); + abortRef.current = controller; + setBusy("scan"); + setProgress({ + completed: 0, + total: files.length, + currentName: files[0]?.name ?? "", + }); + setError(""); + setRecords([]); + try { + const scans = await scanFilesInWorker( + files, + setProgress, + controller.signal, + ); + if (controller.signal.aborted) return; + setRecords(scans.map((scan, index) => ({ file: files[index]!, scan }))); + } catch (caught) { + if (!isAbort(caught)) setError(errorMessage(caught)); + } finally { + if (abortRef.current === controller) { + abortRef.current = null; + setBusy(null); + setProgress(null); + } + if (inputRef.current) inputRef.current.value = ""; + } + }; + + const sanitizeOne = async (id: string) => { + const record = records.find((item) => item.scan.id === id); + if (!record?.scan.cleanable) return; + const controller = new AbortController(); + abortRef.current = controller; + setBusy("sanitize"); + setError(""); + setRecords((current) => + current.map((item) => + item.scan.id === id + ? { ...item, sanitizing: true, error: undefined } + : item, + ), + ); + try { + const asset = await sanitizeStaticImage(record.file, record.scan, { + signal: controller.signal, + }); + setRecords((current) => + current.map((item) => + item.scan.id === id + ? { ...item, asset, sanitizing: false, error: undefined } + : item, + ), + ); + } catch (caught) { + if (!isAbort(caught)) + setRecords((current) => + current.map((item) => + item.scan.id === id + ? { + ...item, + sanitizing: false, + error: errorMessage(caught), + } + : item, + ), + ); + } finally { + if (abortRef.current === controller) abortRef.current = null; + setBusy(null); + } + }; + + const sanitizeAll = async () => { + const pending = records.filter( + (record) => record.scan.cleanable && !record.asset, + ); + if (pending.length === 0) return; + const controller = new AbortController(); + abortRef.current = controller; + setBusy("sanitize"); + setError(""); + for (let index = 0; index < pending.length; index += 1) { + const record = pending[index]; + if (!record || controller.signal.aborted) break; + setProgress({ + completed: index, + total: pending.length, + currentName: record.file.name, + }); + setRecords((current) => + current.map((item) => + item.scan.id === record.scan.id + ? { ...item, sanitizing: true, error: undefined } + : item, + ), + ); + try { + const asset = await sanitizeStaticImage(record.file, record.scan, { + signal: controller.signal, + }); + setRecords((current) => + current.map((item) => + item.scan.id === record.scan.id + ? { ...item, asset, sanitizing: false } + : item, + ), + ); + } catch (caught) { + if (isAbort(caught)) break; + setRecords((current) => + current.map((item) => + item.scan.id === record.scan.id + ? { + ...item, + sanitizing: false, + error: errorMessage(caught), + } + : item, + ), + ); + } + } + if (abortRef.current === controller) abortRef.current = null; + setRecords((current) => + current.map((record) => + record.sanitizing ? { ...record, sanitizing: false } : record, + ), + ); + setProgress(null); + setBusy(null); + }; + + const downloadReport = () => { + setError(""); + try { + const report = createBatchReport( + records.map((record) => record.scan), + assets, + ); + triggerBlobDownload( + new Blob([serializeReport(report)], { type: "application/json" }), + "privacy-tools-report.json", + ); + } catch (caught) { + setError(errorMessage(caught)); + } + }; + + const downloadArchive = async () => { + if (assets.length === 0) return; + setBusy("archive"); + setError(""); + try { + const blob = await createBatchArchive( + records.map((record) => record.scan), + assets, + ); + triggerBlobDownload(blob, "privacy-tools-re-encoded-images.zip"); + } catch (caught) { + setError(errorMessage(caught)); + } finally { + setBusy(null); + } + }; + + const clear = () => { + abortRef.current?.abort(); + abortRef.current = null; + setRecords([]); + setBusy(null); + setProgress(null); + setError(""); + }; + + return ( +
+
+
+

Image metadata workbench

+

Privacy Tools

+

+ Inventory files, inspect static-image metadata, then create and + independently re-scan pixel-only sharing copies—all in this browser. +

+
+ Local & ephemeral +
+ +
+
+
+

Step 1

+

Choose files to inspect

+
+ + 100 files · 128 MiB each · 512 MiB batch + +
+ + { + if (event.currentTarget.files) + void importFiles(event.currentTarget.files); + }} + /> + {busy && progress ? ( +
+ + + {busy === "scan" ? "Inspecting" : "Re-encoding"}{" "} + {progress.currentName} · {progress.completed} of {progress.total} + +
+ ) : null} + {error ? ( +

+ {error} +

+ ) : null} +
+ + {records.length > 0 ? ( + <> +
+
+
+

Step 2

+

Batch inventory

+

+ Detection uses file bytes, not just the extension or browser + claim. +

+
+
+ + {busy === "scan" || busy === "sanitize" ? ( + + ) : null} + +
+
+
+ + + + + + + + + + + + {records.map((record) => ( + + + + + + + + ))} + +
FileClaimedDetectedFindingsClean copy
+ {record.scan.name} + + {formatBytes(record.scan.size)} ·{" "} + {record.scan.sha256.slice(0, 12)}… + + + + {record.scan.identity.claimedType || "not claimed"} + + .{record.scan.identity.extension || "none"} + + {record.scan.identity.detectedType} + + + {record.scan.findings.length} + + {record.scan.coverage.projectScanner} project scan + + + {record.asset ? ( + + ) : record.scan.cleanable ? ( + + ) : ( + Inspect only + )} +
+
+
+ +
+ {records.map((record) => ( + void sanitizeOne(record.scan.id)} + /> + ))} +
+ +
+
+
+

Step 3

+

Export deliberately

+

+ The JSON report includes original filenames and detected + values and may itself be sensitive. +

+
+
+ + +
+
+
+ + ) : null} + + +
+ ); +} + +function FileResult({ + record, + busy, + onSanitize, +}: { + record: FileRecord; + busy: boolean; + onSanitize(): void; +}) { + const grouped = groupFindings(record.scan); + return ( +
+
+
+

+ {record.scan.identity.detectedKind.toUpperCase()} +

+

{record.scan.name}

+

+ {record.scan.width && record.scan.height + ? `${record.scan.width} × ${record.scan.height} pixels · ` + : ""} + SHA-256 {record.scan.sha256} +

+
+
+ {record.scan.cleanable && !record.asset ? ( + + ) : null} + {record.asset ? ( + + ) : null} +
+
+ {record.error ? ( +

+ {record.error} +

+ ) : null} + {record.scan.warnings.length > 0 ? ( +
    + {record.scan.warnings.map((warning) => ( +
  • {warning}
  • + ))} +
+ ) : null} +
+ {grouped.length === 0 ? ( +

+ No recognized metadata findings were reported within scanner + coverage. +

+ ) : ( + grouped.map(([category, findings]) => ( +
finding.risk === "sensitive")} + > + + {CATEGORY_LABELS[category]} + {findings.length} + +
+ {findings.slice(0, 50).map((finding) => ( +
+
+ {finding.label} + {finding.source} +
+ {finding.value || "(empty)"} +
+ ))} + {findings.length > 50 ? ( +

+ {findings.length - 50} more findings are included in the + JSON report. +

+ ) : null} +
+
+ )) + )} +
+ {record.asset ? : null} +
+ ); +} + +function Verification({ report }: { report: SanitizedAsset["report"] }) { + return ( +
+
+
+

Mandatory output re-scan

+

{report.summary}

+
+ +
+
+
+
Output hash
+
+ {report.outputSha256} +
+
+
+
Metadata
+
+ {report.removed.length} removed · {report.preserved.length}{" "} + preserved · {report.generated.length} generated +
+
+
+
Orientation
+
+ {report.orientationNormalized ? "Normalized" : "Review required"} +
+
+
+
Pixel sample
+
+ {report.pixelComparison.identical + ? "Identical" + : "Changed after encoding"} +
+
+
+ {report.generated.length > 0 ? ( +
+ Generated or preserved output metadata +
    + {report.generated.map((finding) => ( +
  • + {finding.label}: {finding.value} +
  • + ))} +
+
+ ) : null} + {[...report.unsupported, ...report.incomplete].length > 0 ? ( +
    + {[...report.unsupported, ...report.incomplete].map((note) => ( +
  • {note}
  • + ))} +
+ ) : null} +

{report.disclaimer}

+
+ ); +} + +function StatusBadge({ status }: { status: string }) { + const normalized = status.replace(/[^a-z]+/gu, "-"); + return {status}; +} + +function groupFindings( + scan: ImageScanResult, +): Array<[FindingCategory, ImageScanResult["findings"]]> { + const groups = new Map(); + for (const finding of scan.findings) { + const values = groups.get(finding.category) ?? []; + values.push(finding); + groups.set(finding.category, values); + } + return [...groups.entries()]; +} + +function formatBytes(value: number): string { + if (value < 1024) return `${value} B`; + if (value < 1024 ** 2) return `${(value / 1024).toFixed(1)} KiB`; + return `${(value / 1024 ** 2).toFixed(1)} MiB`; +} + +function errorMessage(error: unknown): string { + return error instanceof Error ? error.message : "The operation failed."; +} + +function isAbort(error: unknown): boolean { + return error instanceof DOMException && error.name === "AbortError"; +} diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..a1e243e --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,18 @@ +import { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import { App } from "./App"; + +createRoot(document.getElementById("root")!).render( + + + , +); + +if ("serviceWorker" in navigator && import.meta.env.PROD) { + window.addEventListener("load", () => { + const url = new URL("./sw.js", document.baseURI); + void navigator.serviceWorker + .register(url, { scope: new URL("./", document.baseURI).pathname }) + .catch(() => undefined); + }); +} diff --git a/src/privacy/archive.ts b/src/privacy/archive.ts new file mode 100644 index 0000000..090e974 --- /dev/null +++ b/src/privacy/archive.ts @@ -0,0 +1,121 @@ +import { + encodeText, + sanitizeDownloadFilename, + stableStringify, +} from "@add-ideas/toolbox-helpers"; +import { zipSync } from "fflate"; + +import { APP_VERSION } from "../version"; +import { + assertLimit, + DEFAULT_PRIVACY_LIMITS, + PrivacyLimitError, +} from "./limits"; +import type { + BatchReport, + ImageScanResult, + SanitizedAsset, + SanitizationReport, +} from "./model"; + +export function createBatchReport( + files: readonly ImageScanResult[], + assets: readonly SanitizedAsset[], + generatedAt = new Date().toISOString(), +): BatchReport { + return { + schemaVersion: 1, + generatedAt, + application: { name: "Privacy Tools", version: APP_VERSION }, + files: [...files], + sanitizations: assets.map((asset) => asset.report), + warnings: [ + "This report may itself contain sensitive source metadata and filenames; store and share it deliberately.", + "A successful re-scan is not an anonymity guarantee; see each sanitization disclaimer.", + ], + }; +} + +export function serializeReport( + report: BatchReport | SanitizationReport, +): string { + return stableStringify(report, 2, { + maxDepth: 64, + maxNodes: 500_000, + maxTextChars: 2_000_000, + }); +} + +export async function createBatchArchive( + files: readonly ImageScanResult[], + assets: readonly SanitizedAsset[], + generatedAt = new Date().toISOString(), +): Promise { + assertLimit( + files.length, + DEFAULT_PRIVACY_LIMITS.maxFiles, + "Report file count", + ); + assertLimit( + assets.length, + DEFAULT_PRIVACY_LIMITS.maxFiles, + "Archive image count", + ); + const entries: Record = Object.create(null) as Record< + string, + Uint8Array + >; + const names = new Set(); + let total = 0; + for (const asset of assets) { + const name = uniqueName(asset.report.outputName, names); + const bytes = new Uint8Array(await asset.blob.arrayBuffer()); + total += bytes.byteLength; + if (total > DEFAULT_PRIVACY_LIMITS.maxZipBytes) + throw new PrivacyLimitError( + "Batch archive input size", + total, + DEFAULT_PRIVACY_LIMITS.maxZipBytes, + ); + entries[`images/${name}`] = bytes; + } + const report = encodeText( + serializeReport(createBatchReport(files, assets, generatedAt)), + ); + total += report.byteLength; + if (total > DEFAULT_PRIVACY_LIMITS.maxZipBytes) + throw new PrivacyLimitError( + "Batch archive input size", + total, + DEFAULT_PRIVACY_LIMITS.maxZipBytes, + ); + entries["privacy-tools-report.json"] = report; + const archive = zipSync(entries, { + level: 0, + mtime: new Date("1980-01-01T00:00:00.000Z"), + }); + if (archive.byteLength > DEFAULT_PRIVACY_LIMITS.maxZipBytes) + throw new PrivacyLimitError( + "Batch archive output size", + archive.byteLength, + DEFAULT_PRIVACY_LIMITS.maxZipBytes, + ); + const ownedArchive = archive.slice().buffer as ArrayBuffer; + return new Blob([ownedArchive], { type: "application/zip" }); +} + +function uniqueName(input: string, used: Set): string { + const safe = sanitizeDownloadFilename(input, "image.clean"); + if (!used.has(safe)) { + used.add(safe); + return safe; + } + const dot = safe.lastIndexOf("."); + const stem = dot > 0 ? safe.slice(0, dot) : safe; + const extension = dot > 0 ? safe.slice(dot) : ""; + let counter = 2; + while (used.has(`${stem}-${counter}${extension}`)) counter += 1; + const candidate = `${stem}-${counter}${extension}`; + used.add(candidate); + return candidate; +} diff --git a/src/privacy/detect.ts b/src/privacy/detect.ts new file mode 100644 index 0000000..c3c5c40 --- /dev/null +++ b/src/privacy/detect.ts @@ -0,0 +1,149 @@ +import type { DetectedKind, InventoryIdentity } from "./model"; + +const MIME_BY_KIND: Readonly> = Object.freeze({ + jpeg: "image/jpeg", + png: "image/png", + webp: "image/webp", + gif: "image/gif", + tiff: "image/tiff", + heic: "image/heic", + avif: "image/avif", + jxl: "image/jxl", + pdf: "application/pdf", + zip: "application/zip", + ole: "application/x-ole-storage", + unknown: "application/octet-stream", +}); + +const EXTENSIONS: Readonly> = Object.freeze({ + jpg: "jpeg", + jpeg: "jpeg", + jpe: "jpeg", + png: "png", + webp: "webp", + gif: "gif", + tif: "tiff", + tiff: "tiff", + heic: "heic", + heif: "heic", + avif: "avif", + jxl: "jxl", + pdf: "pdf", + zip: "zip", + docx: "zip", + xlsx: "zip", + pptx: "zip", + odt: "zip", + ods: "zip", + odp: "zip", + doc: "ole", + xls: "ole", + ppt: "ole", +}); + +export function fileExtension(name: string): string { + const leaf = name.replace(/\\/gu, "/").split("/").at(-1) ?? ""; + const index = leaf.lastIndexOf("."); + return index > 0 && index < leaf.length - 1 + ? leaf.slice(index + 1).toLowerCase() + : ""; +} + +export function detectKind(bytes: Uint8Array): DetectedKind { + if (starts(bytes, [0xff, 0xd8, 0xff])) return "jpeg"; + if (starts(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])) + return "png"; + if (ascii(bytes, 0, 4) === "RIFF" && ascii(bytes, 8, 4) === "WEBP") + return "webp"; + if (ascii(bytes, 0, 6) === "GIF87a" || ascii(bytes, 0, 6) === "GIF89a") + return "gif"; + if ( + starts(bytes, [0x49, 0x49, 0x2a, 0x00]) || + starts(bytes, [0x4d, 0x4d, 0x00, 0x2a]) + ) + return "tiff"; + if (starts(bytes, [0x25, 0x50, 0x44, 0x46, 0x2d])) return "pdf"; + if ( + starts(bytes, [0x50, 0x4b, 0x03, 0x04]) || + starts(bytes, [0x50, 0x4b, 0x05, 0x06]) || + starts(bytes, [0x50, 0x4b, 0x07, 0x08]) + ) + return "zip"; + if (starts(bytes, [0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1])) + return "ole"; + if (starts(bytes, [0xff, 0x0a])) return "jxl"; + if ( + starts( + bytes, + [0x00, 0x00, 0x00, 0x0c, 0x4a, 0x58, 0x4c, 0x20, 0x0d, 0x0a, 0x87, 0x0a], + ) + ) + return "jxl"; + const brand = isoBmffBrand(bytes); + if (["avif", "avis"].includes(brand)) return "avif"; + if (["heic", "heix", "hevc", "hevx", "mif1", "msf1"].includes(brand)) + return "heic"; + return "unknown"; +} + +export function inventoryIdentity( + name: string, + claimedType: string, + bytes: Uint8Array, +): InventoryIdentity { + const extension = fileExtension(name); + const detectedKind = detectKind(bytes); + const detectedType = MIME_BY_KIND[detectedKind]; + const normalizedClaim = claimedType.trim().toLowerCase(); + const extensionKind = EXTENSIONS[extension]; + const claimedMatches = + !normalizedClaim || normalizedClaim === "application/octet-stream" + ? undefined + : normalizeMime(normalizedClaim) === detectedType; + const extensionMatches = !extensionKind || extensionKind === detectedKind; + const typeMatch = + detectedKind === "unknown" + ? "unknown" + : claimedMatches === false || !extensionMatches + ? "mismatch" + : claimedMatches === undefined && !extensionKind + ? "unclaimed" + : "match"; + return { + claimedType: normalizedClaim, + extension, + detectedKind, + detectedType, + typeMatch, + }; +} + +function normalizeMime(value: string): string { + if (value === "image/jpg" || value === "image/pjpeg") return "image/jpeg"; + if (value === "image/x-png") return "image/png"; + if (value === "image/heif") return "image/heic"; + return value; +} + +function starts(bytes: Uint8Array, signature: readonly number[]): boolean { + return signature.every((value, index) => bytes[index] === value); +} + +function ascii(bytes: Uint8Array, offset: number, length: number): string { + if (offset < 0 || length < 0 || offset + length > bytes.byteLength) return ""; + let result = ""; + for (let index = 0; index < length; index += 1) + result += String.fromCharCode(bytes[offset + index] ?? 0); + return result; +} + +function isoBmffBrand(bytes: Uint8Array): string { + if (bytes.byteLength < 12 || ascii(bytes, 4, 4) !== "ftyp") return ""; + const length = + ((bytes[0] ?? 0) << 24) | + ((bytes[1] ?? 0) << 16) | + ((bytes[2] ?? 0) << 8) | + (bytes[3] ?? 0); + if (length < 12 || length > bytes.byteLength) return ""; + return ascii(bytes, 8, 4).toLowerCase(); +} diff --git a/src/privacy/exif-reader-adapter.ts b/src/privacy/exif-reader-adapter.ts new file mode 100644 index 0000000..6279ce3 --- /dev/null +++ b/src/privacy/exif-reader-adapter.ts @@ -0,0 +1,141 @@ +import ExifReader, { type ExpandedTags } from "exifreader"; + +import { categoryForName, FindingCollector } from "./findings"; +import type { PrivacyLimits } from "./model"; +import { scanXmp } from "./xmp"; + +export interface SecondaryScan { + status: "complete" | "partial" | "unsupported" | "failed"; + width?: number; + height?: number; + notes: string[]; +} + +const GROUP_LABELS: Readonly> = Object.freeze({ + exif: "ExifReader EXIF", + iptc: "ExifReader IPTC", + icc: "ExifReader ICC", + jfif: "ExifReader JFIF", + png: "ExifReader PNG", + pngText: "ExifReader PNG text", + riff: "ExifReader WebP", + gps: "ExifReader GPS", + photoshop: "ExifReader Photoshop", + makerNotes: "ExifReader maker notes", + composite: "ExifReader computed", +}); + +export function scanWithExifReader( + bytes: ArrayBuffer, + collector: FindingCollector, + limits: Readonly, +): SecondaryScan { + try { + const tags = ExifReader.load(bytes, { + expanded: true, + async: false, + computed: true, + includeUnknown: false, + excludeTags: { xmp: true, mpf: true }, + decompress: { maxDecompressedSize: limits.maxInflatedMetadataBytes }, + }); + const fileType = tags.file?.FileType?.value; + if (!fileType) + return { + status: "unsupported", + notes: ["ExifReader did not recognize this format."], + }; + const width = numericTag(tags.file?.["Image Width"]); + const height = numericTag(tags.file?.["Image Height"]); + let nodes = 0; + for (const [groupName, source] of Object.entries(GROUP_LABELS)) { + const group = tags[groupName as keyof ExpandedTags] as unknown; + if (!group || typeof group !== "object") continue; + for (const [name, tag] of Object.entries(group)) { + nodes += 1; + if (nodes > limits.maxFindings) { + collector.warn( + "ExifReader finding count reached the application limit.", + ); + return { + status: "partial", + width, + height, + notes: ["ExifReader output was truncated at the finding limit."], + }; + } + if (name.startsWith("_") || name === "base64" || name === "image") + continue; + const value = tagValue(tag); + if (!value) continue; + const classification = + groupName === "gps" + ? ({ category: "location", risk: "sensitive" } as const) + : categoryForName(`${groupName} ${name}`); + collector.add({ + ...classification, + source, + label: name, + value, + }); + } + } + if (tags.Thumbnail) { + const image = tags.Thumbnail.image; + const length = + image instanceof ArrayBuffer || image instanceof SharedArrayBuffer + ? image.byteLength + : image?.byteLength; + collector.add({ + category: "thumbnail", + risk: "sensitive", + source: "ExifReader thumbnail", + label: "Embedded thumbnail", + value: `${length ?? "unknown"} bytes`, + }); + } + const rawXmp = tags.xmp?._raw; + if (typeof rawXmp === "string") + scanXmp(rawXmp, "ExifReader XMP", undefined, collector); + if (width === undefined || height === undefined) + return { + status: "partial", + width, + height, + notes: [ + "ExifReader recognized the container but could not establish both pixel dimensions.", + ], + }; + return { status: "complete", width, height, notes: [] }; + } catch (error) { + return { + status: "failed", + notes: [ + `ExifReader could not complete: ${error instanceof Error ? error.message : "unknown error"}`, + ], + }; + } +} + +function numericTag(tag: unknown): number | undefined { + if (!tag || typeof tag !== "object") return undefined; + const value = (tag as { value?: unknown }).value; + return typeof value === "number" && Number.isFinite(value) + ? value + : undefined; +} + +function tagValue(tag: unknown): string { + if (tag == null) return ""; + if (typeof tag === "string" || typeof tag === "number") return String(tag); + if (Array.isArray(tag)) return tag.slice(0, 128).map(tagValue).join(", "); + if (ArrayBuffer.isView(tag)) return `${tag.byteLength} bytes`; + if (tag instanceof ArrayBuffer || tag instanceof SharedArrayBuffer) + return `${tag.byteLength} bytes`; + if (typeof tag === "object") { + const item = tag as { description?: unknown; value?: unknown }; + if (typeof item.description === "string") return item.description; + if (item.value !== undefined) return tagValue(item.value); + } + return ""; +} diff --git a/src/privacy/findings.ts b/src/privacy/findings.ts new file mode 100644 index 0000000..d902600 --- /dev/null +++ b/src/privacy/findings.ts @@ -0,0 +1,159 @@ +import type { + FindingCategory, + FindingRisk, + MetadataFinding, + PrivacyLimits, +} from "./model"; + +export class FindingCollector { + readonly findings: MetadataFinding[] = []; + readonly warnings: string[] = []; + limited = false; + readonly #keys = new Set(); + readonly #limits: Readonly; + #textChars = 0; + + constructor(limits: Readonly) { + this.#limits = limits; + } + + add( + finding: Omit & { + id?: string; + value: unknown; + }, + ): void { + if (this.limited) return; + const source = boundedLabel( + finding.source, + this.#limits.maxFindingLabelChars, + ); + const label = boundedLabel( + finding.label, + this.#limits.maxFindingLabelChars, + ); + let value = displayValue(finding.value); + if (value.length > this.#limits.maxFindingValueChars) { + value = `${value.slice(0, this.#limits.maxFindingValueChars)}…`; + this.warn( + `${source} ${label} was truncated to ${this.#limits.maxFindingValueChars} characters.`, + ); + } + const key = `${source}\u0000${label}\u0000${value}\u0000${finding.offset ?? ""}`; + if (this.#keys.has(key)) return; + const addedText = source.length + label.length + value.length; + if ( + this.findings.length >= this.#limits.maxFindings || + this.#textChars + addedText > this.#limits.maxFindingTextChars + ) { + this.limited = true; + this.warn( + `Metadata findings were truncated at ${this.#limits.maxFindings} entries or ${this.#limits.maxFindingTextChars} text characters.`, + ); + return; + } + this.#keys.add(key); + this.#textChars += addedText; + this.findings.push({ + ...finding, + source, + label, + id: + finding.id ?? + `${source.toLowerCase().replace(/[^a-z0-9]+/gu, "-")}-${this.findings.length + 1}`, + value, + }); + } + + warn(message: string): void { + if (!this.warnings.includes(message)) this.warnings.push(message); + } +} + +function boundedLabel(value: string, maximum: number): string { + const sanitized = sanitizeText(value); + return sanitized.length <= maximum + ? sanitized + : `${sanitized.slice(0, Math.max(0, maximum - 1))}…`; +} + +export function categoryForName(name: string): { + category: FindingCategory; + risk: FindingRisk; +} { + const normalized = name.toLowerCase(); + if ( + /(?:gps|latitude|longitude|location|city|country|province|state|sublocation|altitude)/u.test( + normalized, + ) + ) + return { category: "location", risk: "sensitive" }; + if ( + /(?:artist|author|creator|byline|credit|owner|person|copyright|rights|email)/u.test( + normalized, + ) + ) + return { category: "identity", risk: "sensitive" }; + if (/(?:date|time|created|modified|timestamp)/u.test(normalized)) + return { category: "timestamp", risk: "sensitive" }; + if ( + /(?:serial|camera|device|make|model|lens|makernote|ownername)/u.test( + normalized, + ) + ) + return { category: "device", risk: "sensitive" }; + if ( + /(?:software|history|creatortool|processing|hostcomputer)/u.test(normalized) + ) + return { category: "software", risk: "sensitive" }; + if ( + /(?:documentid|instanceid|uniqueid|originaldocumentid|assetid)/u.test( + normalized, + ) + ) + return { category: "document-id", risk: "sensitive" }; + if ( + /(?:comment|description|caption|headline|keyword|subject|title)/u.test( + normalized, + ) + ) + return { category: "comment", risk: "context" }; + if (/(?:thumbnail|preview)/u.test(normalized)) + return { category: "thumbnail", risk: "sensitive" }; + if (/(?:icc|profile|colorspace|colourspace)/u.test(normalized)) + return { category: "colour-profile", risk: "technical" }; + if (/(?:c2pa|jumbf|provenance|manifest|signature)/u.test(normalized)) + return { category: "provenance", risk: "context" }; + if ( + /(?:orientation|resolution|jfif|density|dimensions|pixel)/u.test(normalized) + ) + return { category: "technical", risk: "technical" }; + return { category: "unknown", risk: "context" }; +} + +function displayValue(value: unknown): string { + if (value == null) return ""; + if (typeof value === "string") return sanitizeText(value); + if (typeof value === "number" || typeof value === "bigint") + return String(value); + if (typeof value === "boolean") return value ? "Yes" : "No"; + if (value instanceof Uint8Array) return `${value.byteLength} bytes`; + if (Array.isArray(value)) return value.map(displayValue).join(", "); + try { + return sanitizeText(JSON.stringify(value)); + } catch { + return String(value); + } +} + +function sanitizeText(value: string): string { + return Array.from(value, (character) => { + const point = character.codePointAt(0) ?? 0; + if (point === 0) return "�"; + if ((point >= 1 && point <= 8) || point === 11 || point === 12) return " "; + if ((point >= 14 && point <= 31) || point === 127) return " "; + return character; + }) + .join("") + .trim(); +} diff --git a/src/privacy/index.ts b/src/privacy/index.ts new file mode 100644 index 0000000..b92c06a --- /dev/null +++ b/src/privacy/index.ts @@ -0,0 +1,7 @@ +export * from "./archive"; +export * from "./detect"; +export * from "./limits"; +export * from "./model"; +export * from "./sanitize"; +export * from "./scan-client"; +export * from "./scanner"; diff --git a/src/privacy/inflate.ts b/src/privacy/inflate.ts new file mode 100644 index 0000000..70894a4 --- /dev/null +++ b/src/privacy/inflate.ts @@ -0,0 +1,29 @@ +import { Unzlib } from "fflate"; + +import { PrivacyLimitError } from "./limits"; + +export function inflateZlibBounded( + input: Uint8Array, + maximumBytes: number, +): Uint8Array { + const chunks: Uint8Array[] = []; + let total = 0; + const inflater = new Unzlib((chunk) => { + total += chunk.byteLength; + if (total > maximumBytes) + throw new PrivacyLimitError( + "Inflated metadata size", + total, + maximumBytes, + ); + chunks.push(chunk.slice()); + }); + inflater.push(input, true); + const output = new Uint8Array(total); + let offset = 0; + for (const chunk of chunks) { + output.set(chunk, offset); + offset += chunk.byteLength; + } + return output; +} diff --git a/src/privacy/iptc.ts b/src/privacy/iptc.ts new file mode 100644 index 0000000..471ffaf --- /dev/null +++ b/src/privacy/iptc.ts @@ -0,0 +1,128 @@ +import { categoryForName, FindingCollector } from "./findings"; + +const DATASET_NAMES: Readonly> = Object.freeze({ + 5: "Object Name", + 25: "Keywords", + 55: "Date Created", + 60: "Time Created", + 80: "By-line", + 85: "By-line Title", + 90: "City", + 92: "Sublocation", + 95: "Province/State", + 100: "Country Code", + 101: "Country", + 105: "Headline", + 110: "Credit", + 115: "Source", + 116: "Copyright Notice", + 120: "Caption/Abstract", + 122: "Writer/Editor", +}); + +export function scanIptc( + bytes: Uint8Array, + source: string, + baseOffset: number, + collector: FindingCollector, +): void { + let offset = 0; + let datasets = 0; + while (offset + 5 <= bytes.byteLength) { + if (bytes[offset] !== 0x1c) { + offset += 1; + continue; + } + const record = bytes[offset + 1] ?? 0; + const dataset = bytes[offset + 2] ?? 0; + let length = ((bytes[offset + 3] ?? 0) << 8) | (bytes[offset + 4] ?? 0); + let header = 5; + if ((length & 0x8000) !== 0) { + const lengthBytes = length & 0x7fff; + if ( + lengthBytes < 1 || + lengthBytes > 4 || + offset + 5 + lengthBytes > bytes.byteLength + ) { + collector.warn(`${source} contains an invalid extended IPTC length.`); + return; + } + length = 0; + for (let index = 0; index < lengthBytes; index += 1) + length = length * 256 + (bytes[offset + 5 + index] ?? 0); + header += lengthBytes; + } + if (length > 1024 * 1024 || offset + header + length > bytes.byteLength) { + collector.warn( + `${source} contains a truncated or oversized IPTC dataset.`, + ); + return; + } + const valueBytes = bytes.subarray( + offset + header, + offset + header + length, + ); + const label = + record === 2 + ? (DATASET_NAMES[dataset] ?? `IPTC 2:${dataset}`) + : `IPTC ${record}:${dataset}`; + const classification = categoryForName(label); + collector.add({ + ...classification, + source, + label, + value: new TextDecoder("utf-8", { fatal: false }).decode(valueBytes), + offset: baseOffset + offset, + length: header + length, + }); + datasets += 1; + if (datasets > 2048) { + collector.warn(`${source} IPTC dataset count exceeded 2048.`); + return; + } + offset += header + length; + } +} + +export function findPhotoshopIptc( + bytes: Uint8Array, +): Array<{ bytes: Uint8Array; relativeOffset: number }> { + const result: Array<{ bytes: Uint8Array; relativeOffset: number }> = []; + let offset = bytes.byteLength >= 14 ? 14 : 0; + while (offset + 12 <= bytes.byteLength) { + if ( + bytes[offset] !== 0x38 || + bytes[offset + 1] !== 0x42 || + bytes[offset + 2] !== 0x49 || + bytes[offset + 3] !== 0x4d + ) { + offset += 1; + continue; + } + const resource = ((bytes[offset + 4] ?? 0) << 8) | (bytes[offset + 5] ?? 0); + const nameLength = bytes[offset + 6] ?? 0; + const paddedName = 1 + nameLength + ((1 + nameLength) % 2); + const sizeOffset = offset + 6 + paddedName; + if (sizeOffset + 4 > bytes.byteLength) break; + const length = readU32be(bytes, sizeOffset); + const dataOffset = sizeOffset + 4; + if (length > 8 * 1024 * 1024 || dataOffset + length > bytes.byteLength) + break; + if (resource === 0x0404) + result.push({ + bytes: bytes.subarray(dataOffset, dataOffset + length), + relativeOffset: dataOffset, + }); + offset = dataOffset + length + (length % 2); + } + return result; +} + +function readU32be(bytes: Uint8Array, offset: number): number { + return ( + (bytes[offset] ?? 0) * 0x1000000 + + ((bytes[offset + 1] ?? 0) << 16) + + ((bytes[offset + 2] ?? 0) << 8) + + (bytes[offset + 3] ?? 0) + ); +} diff --git a/src/privacy/jpeg.ts b/src/privacy/jpeg.ts new file mode 100644 index 0000000..2b7c01a --- /dev/null +++ b/src/privacy/jpeg.ts @@ -0,0 +1,323 @@ +import { FindingCollector } from "./findings"; +import { findPhotoshopIptc, scanIptc } from "./iptc"; +import type { MetadataBlock, PrivacyLimits } from "./model"; +import { scanTiff } from "./tiff"; +import { decodeMetadataText, scanXmp } from "./xmp"; + +export interface FormatScan { + width?: number; + height?: number; + orientation?: number; + animated: boolean; + multiImage: boolean; + complete: boolean; + blocks: MetadataBlock[]; +} + +const XMP_HEADER = "http://ns.adobe.com/xap/1.0/\u0000"; +const XMP_EXTENDED_HEADER = "http://ns.adobe.com/xmp/extension/\u0000"; + +export function scanJpeg( + bytes: Uint8Array, + collector: FindingCollector, + limits: Readonly, +): FormatScan { + const blocks: MetadataBlock[] = []; + if (bytes.byteLength < 4 || bytes[0] !== 0xff || bytes[1] !== 0xd8) { + collector.warn("JPEG start-of-image marker is missing."); + return { animated: false, multiImage: false, complete: false, blocks }; + } + let offset = 2; + let complete = true; + let width: number | undefined; + let height: number | undefined; + let orientation: number | undefined; + let multiImage = false; + let segments = 0; + let enteredScan = false; + while (offset < bytes.byteLength) { + if (bytes[offset] !== 0xff) { + collector.warn(`JPEG marker sync was lost at byte ${offset}.`); + complete = false; + break; + } + while (offset < bytes.byteLength && bytes[offset] === 0xff) offset += 1; + if (offset >= bytes.byteLength) { + complete = false; + break; + } + const marker = bytes[offset] ?? 0; + offset += 1; + if (marker === 0xd9) break; + if (marker === 0xda) { + enteredScan = true; + break; + } + if (marker === 0x01 || (marker >= 0xd0 && marker <= 0xd8)) continue; + if (offset + 2 > bytes.byteLength) { + collector.warn("JPEG segment length is truncated."); + complete = false; + break; + } + const segmentLength = + ((bytes[offset] ?? 0) << 8) | (bytes[offset + 1] ?? 0); + if (segmentLength < 2 || offset + segmentLength > bytes.byteLength) { + collector.warn( + `JPEG marker 0x${marker.toString(16)} has an invalid length.`, + ); + complete = false; + break; + } + segments += 1; + if (segments > limits.maxMetadataBlocks) { + collector.warn( + `JPEG segment count exceeded ${limits.maxMetadataBlocks}.`, + ); + complete = false; + break; + } + const dataOffset = offset + 2; + const dataLength = segmentLength - 2; + const data = bytes.subarray(dataOffset, dataOffset + dataLength); + if (isStartOfFrame(marker) && data.byteLength >= 5) { + height = ((data[1] ?? 0) << 8) | (data[2] ?? 0); + width = ((data[3] ?? 0) << 8) | (data[4] ?? 0); + } + if (marker >= 0xe0 && marker <= 0xef) { + if (dataLength > limits.maxMetadataBlockBytes) { + collector.warn( + `JPEG APP${marker - 0xe0} metadata exceeds the block limit.`, + ); + complete = false; + } else { + blocks.push({ + kind: `APP${marker - 0xe0}`, + offset: dataOffset, + length: dataLength, + }); + const result = scanJpegApplication( + marker, + data, + dataOffset, + collector, + limits, + ); + if (result.orientation !== undefined) orientation = result.orientation; + multiImage ||= result.multiImage; + complete &&= result.complete; + } + } else if (marker === 0xfe) { + blocks.push({ kind: "COM", offset: dataOffset, length: dataLength }); + collector.add({ + category: "comment", + risk: "context", + source: "JPEG COM", + label: "Comment", + value: decodeMetadataText(data), + offset: dataOffset, + length: dataLength, + }); + } + offset += segmentLength; + } + const eoi = enteredScan + ? findJpegEnd(bytes, offset) + : bytes.lastIndexOf(0xd9); + if (eoi < 1 || bytes[eoi - 1] !== 0xff) { + collector.warn("JPEG end-of-image marker was not found."); + complete = false; + } else if (eoi + 1 < bytes.byteLength) { + const trailing = bytes.byteLength - eoi - 1; + blocks.push({ kind: "trailing-data", offset: eoi + 1, length: trailing }); + collector.add({ + category: "unknown", + risk: "sensitive", + source: "JPEG", + label: "Trailing data", + value: `${trailing} bytes after end-of-image`, + offset: eoi + 1, + length: trailing, + }); + } + return { + width, + height, + orientation, + animated: false, + multiImage, + complete, + blocks, + }; +} + +function scanJpegApplication( + marker: number, + data: Uint8Array, + offset: number, + collector: FindingCollector, + limits: Readonly, +): { orientation?: number; multiImage: boolean; complete: boolean } { + if (marker === 0xe0 && ascii(data, 0, 5) === "JFIF\u0000") { + const thumbnailWidth = data[12] ?? 0; + const thumbnailHeight = data[13] ?? 0; + collector.add({ + category: thumbnailWidth && thumbnailHeight ? "thumbnail" : "technical", + risk: thumbnailWidth && thumbnailHeight ? "sensitive" : "technical", + source: "JPEG APP0", + label: "JFIF header", + value: `version ${data[5] ?? 0}.${String(data[6] ?? 0).padStart(2, "0")}; density ${readU16be(data, 8)}×${readU16be(data, 10)}; thumbnail ${thumbnailWidth}×${thumbnailHeight}`, + offset, + length: data.byteLength, + }); + return { multiImage: false, complete: true }; + } + if (marker === 0xe1 && ascii(data, 0, 6) === "Exif\u0000\u0000") { + const result = scanTiff( + data.subarray(6), + "JPEG EXIF", + offset + 6, + collector, + limits, + ); + return { + orientation: result.orientation, + multiImage: false, + complete: result.complete, + }; + } + if (marker === 0xe1 && ascii(data, 0, XMP_HEADER.length) === XMP_HEADER) { + scanXmp(data.subarray(XMP_HEADER.length), "JPEG XMP", offset, collector); + return { multiImage: false, complete: true }; + } + if ( + marker === 0xe1 && + ascii(data, 0, XMP_EXTENDED_HEADER.length) === XMP_EXTENDED_HEADER + ) { + scanXmp( + data.subarray(XMP_EXTENDED_HEADER.length), + "JPEG extended XMP", + offset, + collector, + ); + return { multiImage: false, complete: true }; + } + if (marker === 0xed && ascii(data, 0, 13) === "Photoshop 3.0") { + const resources = findPhotoshopIptc(data); + for (const resource of resources) + scanIptc( + resource.bytes, + "JPEG IPTC", + offset + resource.relativeOffset, + collector, + ); + if (resources.length === 0) + collector.add({ + category: "unknown", + risk: "context", + source: "JPEG APP13", + label: "Photoshop image resources", + value: `${data.byteLength} bytes`, + offset, + length: data.byteLength, + }); + return { multiImage: false, complete: true }; + } + if (marker === 0xe2 && ascii(data, 0, 12) === "ICC_PROFILE\u0000") { + collector.add({ + category: "colour-profile", + risk: "technical", + source: "JPEG APP2", + label: "ICC profile chunk", + value: `chunk ${data[12] ?? 0} of ${data[13] ?? 0}; ${Math.max(0, data.byteLength - 14)} bytes`, + offset, + length: data.byteLength, + }); + return { multiImage: false, complete: true }; + } + if (marker === 0xe2 && ascii(data, 0, 4) === "MPF\u0000") { + collector.add({ + category: "thumbnail", + risk: "sensitive", + source: "JPEG APP2", + label: "Multi-Picture Format", + value: `${data.byteLength} bytes; additional images may be embedded`, + offset, + length: data.byteLength, + }); + return { multiImage: true, complete: true }; + } + if (marker === 0xeb && containsAscii(data, ["jumb", "c2pa"])) { + collector.add({ + category: "provenance", + risk: "context", + source: "JPEG APP11", + label: "JUMBF / C2PA provenance data", + value: `${data.byteLength} bytes; re-encoding will remove or invalidate this provenance`, + offset, + length: data.byteLength, + }); + return { multiImage: false, complete: true }; + } + if (marker === 0xee && ascii(data, 0, 5) === "Adobe") { + collector.add({ + category: "technical", + risk: "technical", + source: "JPEG APP14", + label: "Adobe colour transform header", + value: `${data.byteLength} bytes`, + offset, + length: data.byteLength, + }); + return { multiImage: false, complete: true }; + } + collector.add({ + category: containsAscii(data, ["c2pa", "jumb"]) ? "provenance" : "unknown", + risk: "context", + source: `JPEG APP${marker - 0xe0}`, + label: "Unrecognized application metadata", + value: `${data.byteLength} bytes`, + offset, + length: data.byteLength, + }); + return { multiImage: false, complete: true }; +} + +function isStartOfFrame(marker: number): boolean { + return ( + marker >= 0xc0 && marker <= 0xcf && ![0xc4, 0xc8, 0xcc].includes(marker) + ); +} + +function findJpegEnd(bytes: Uint8Array, offset: number): number { + for (let index = offset; index + 1 < bytes.byteLength; index += 1) { + if (bytes[index] !== 0xff) continue; + const marker = bytes[index + 1] ?? 0; + if (marker === 0x00 || (marker >= 0xd0 && marker <= 0xd7)) { + index += 1; + continue; + } + if (marker === 0xd9) return index + 1; + } + return -1; +} + +function ascii(bytes: Uint8Array, offset: number, length: number): string { + if (offset < 0 || offset + length > bytes.byteLength) return ""; + let result = ""; + for (let index = 0; index < length; index += 1) + result += String.fromCharCode(bytes[offset + index] ?? 0); + return result; +} + +function containsAscii(bytes: Uint8Array, needles: readonly string[]): boolean { + const sample = ascii( + bytes.subarray(0, Math.min(bytes.byteLength, 4096)), + 0, + Math.min(bytes.byteLength, 4096), + ).toLowerCase(); + return needles.some((needle) => sample.includes(needle)); +} + +function readU16be(bytes: Uint8Array, offset: number): number { + return ((bytes[offset] ?? 0) << 8) | (bytes[offset + 1] ?? 0); +} diff --git a/src/privacy/limits.ts b/src/privacy/limits.ts new file mode 100644 index 0000000..8a5325b --- /dev/null +++ b/src/privacy/limits.ts @@ -0,0 +1,73 @@ +import type { PrivacyLimits } from "./model"; + +export const DEFAULT_PRIVACY_LIMITS: Readonly = Object.freeze({ + maxFiles: 100, + maxFileBytes: 128 * 1024 * 1024, + maxBatchBytes: 512 * 1024 * 1024, + maxMetadataBlocks: 4096, + maxMetadataBlockBytes: 8 * 1024 * 1024, + maxInflatedMetadataBytes: 4 * 1024 * 1024, + maxFindingLabelChars: 512, + maxFindingValueChars: 16_384, + maxFindingTextChars: 256 * 1024, + maxFindings: 4096, + maxTiffEntries: 4096, + maxTiffDepth: 16, + maxPixels: 40_000_000, + maxEdge: 32_768, + maxZipBytes: 256 * 1024 * 1024, +}); + +export class PrivacyLimitError extends RangeError { + readonly actual: number; + readonly limit: number; + + constructor(label: string, actual: number, limit: number) { + super(`${label} is ${actual}; the limit is ${limit}`); + this.name = "PrivacyLimitError"; + this.actual = actual; + this.limit = limit; + } +} + +export function assertLimit( + actual: number, + limit: number, + label: string, +): void { + if (!Number.isSafeInteger(actual) || actual < 0) + throw new TypeError(`${label} is not a valid non-negative integer`); + if (!Number.isSafeInteger(limit) || limit <= 0) + throw new TypeError(`${label} limit is not a positive safe integer`); + if (actual > limit) throw new PrivacyLimitError(label, actual, limit); +} + +export function resolveLimits( + overrides: Partial = {}, +): Readonly { + const merged = { ...DEFAULT_PRIVACY_LIMITS, ...overrides }; + for (const [name, value] of Object.entries(merged)) { + if (!Number.isSafeInteger(value) || value <= 0) + throw new TypeError(`${name} must be a positive safe integer`); + } + return Object.freeze(merged); +} + +export function assertBatchFiles( + files: readonly { size: number }[], + limits: Readonly = DEFAULT_PRIVACY_LIMITS, +): void { + assertLimit(files.length, limits.maxFiles, "File count"); + let total = 0; + for (const file of files) { + assertLimit(file.size, limits.maxFileBytes, "File size"); + total += file.size; + if (!Number.isSafeInteger(total)) + throw new PrivacyLimitError( + "Batch byte size", + Number.MAX_SAFE_INTEGER, + limits.maxBatchBytes, + ); + assertLimit(total, limits.maxBatchBytes, "Batch byte size"); + } +} diff --git a/src/privacy/model.ts b/src/privacy/model.ts new file mode 100644 index 0000000..2cb3a57 --- /dev/null +++ b/src/privacy/model.ts @@ -0,0 +1,156 @@ +export type DetectedKind = + | "jpeg" + | "png" + | "webp" + | "gif" + | "tiff" + | "heic" + | "avif" + | "jxl" + | "pdf" + | "zip" + | "ole" + | "unknown"; + +export type FindingCategory = + | "location" + | "identity" + | "timestamp" + | "device" + | "software" + | "document-id" + | "comment" + | "thumbnail" + | "colour-profile" + | "provenance" + | "technical" + | "unknown"; + +export type FindingRisk = "sensitive" | "context" | "technical"; + +export interface MetadataFinding { + id: string; + category: FindingCategory; + risk: FindingRisk; + source: string; + label: string; + value: string; + offset?: number; + length?: number; +} + +export interface MetadataBlock { + kind: string; + offset: number; + length: number; +} + +export interface ParserCoverage { + projectScanner: "complete" | "partial" | "unsupported"; + secondaryScanner: "complete" | "partial" | "unsupported" | "failed"; + notes: string[]; +} + +export interface InventoryIdentity { + claimedType: string; + extension: string; + detectedKind: DetectedKind; + detectedType: string; + typeMatch: "match" | "mismatch" | "unclaimed" | "unknown"; +} + +export interface ImageScanResult { + id: string; + name: string; + safeName: string; + size: number; + lastModified: number; + sha256: string; + identity: InventoryIdentity; + width?: number; + height?: number; + orientation?: number; + animated: boolean; + multiImage: boolean; + deepSupported: boolean; + cleanable: boolean; + findings: MetadataFinding[]; + blocks: MetadataBlock[]; + warnings: string[]; + coverage: ParserCoverage; +} + +export interface ScanInput { + id: string; + name: string; + claimedType: string; + size: number; + lastModified: number; + bytes: ArrayBuffer; +} + +export type SanitizationStatus = "verified" | "warning" | "failed"; + +export interface PixelComparison { + method: "oriented-256px-sample"; + sourceDigest: string; + outputDigest: string; + identical: boolean; + note: string; +} + +export interface SanitizationReport { + sourceId: string; + sourceName: string; + outputName: string; + outputType: string; + sourceSha256: string; + outputSha256: string; + sourceBytes: number; + outputBytes: number; + sourceDimensions?: { width: number; height: number }; + outputDimensions?: { width: number; height: number }; + orientationNormalized: boolean; + removed: MetadataFinding[]; + preserved: MetadataFinding[]; + generated: MetadataFinding[]; + unsupported: string[]; + incomplete: string[]; + outputScan: ImageScanResult; + pixelComparison: PixelComparison; + status: SanitizationStatus; + summary: string; + disclaimer: string; +} + +export interface SanitizedAsset { + blob: Blob; + report: SanitizationReport; +} + +export interface BatchReport { + schemaVersion: 1; + generatedAt: string; + application: { name: "Privacy Tools"; version: "0.1.0" }; + files: ImageScanResult[]; + sanitizations: SanitizationReport[]; + warnings: string[]; +} + +export interface PrivacyLimits { + maxFiles: number; + maxFileBytes: number; + maxBatchBytes: number; + maxMetadataBlocks: number; + maxMetadataBlockBytes: number; + maxInflatedMetadataBytes: number; + maxFindingLabelChars: number; + maxFindingValueChars: number; + maxFindingTextChars: number; + maxFindings: number; + maxTiffEntries: number; + maxTiffDepth: number; + maxPixels: number; + maxEdge: number; + maxZipBytes: number; +} diff --git a/src/privacy/png.ts b/src/privacy/png.ts new file mode 100644 index 0000000..4c1df90 --- /dev/null +++ b/src/privacy/png.ts @@ -0,0 +1,359 @@ +import { crc32 } from "@add-ideas/toolbox-helpers"; + +import { FindingCollector } from "./findings"; +import { inflateZlibBounded } from "./inflate"; +import type { MetadataBlock, PrivacyLimits } from "./model"; +import type { FormatScan } from "./jpeg"; +import { scanTiff } from "./tiff"; +import { decodeMetadataText, scanXmp } from "./xmp"; + +export function scanPng( + bytes: Uint8Array, + collector: FindingCollector, + limits: Readonly, +): FormatScan { + const blocks: MetadataBlock[] = []; + let offset = 8; + let width: number | undefined; + let height: number | undefined; + let orientation: number | undefined; + let animated = false; + let complete = true; + let chunks = 0; + let sawEnd = false; + let sawHeader = false; + let sawImageData = false; + while (offset + 12 <= bytes.byteLength) { + const length = readU32be(bytes, offset); + const type = ascii(bytes, offset + 4, 4); + const dataOffset = offset + 8; + const end = dataOffset + length; + if (!/^[A-Za-z]{4}$/u.test(type) || end + 4 > bytes.byteLength) { + collector.warn(`PNG chunk at byte ${offset} is malformed or truncated.`); + complete = false; + break; + } + chunks += 1; + if (chunks > limits.maxMetadataBlocks) { + collector.warn(`PNG chunk count exceeded ${limits.maxMetadataBlocks}.`); + complete = false; + break; + } + const data = bytes.subarray(dataOffset, end); + const expectedCrc = readU32be(bytes, end); + const crcInput = bytes.subarray(offset + 4, end); + if (crc32(crcInput, limits.maxFileBytes) !== expectedCrc) { + collector.warn(`PNG ${type} chunk at byte ${offset} has an invalid CRC.`); + complete = false; + } + if (chunks === 1 && type !== "IHDR") { + collector.warn("PNG IHDR is not the first chunk."); + complete = false; + } + if (type === "IHDR") { + if (sawHeader || chunks !== 1 || length !== 13) { + collector.warn("PNG IHDR is duplicated, misplaced, or malformed."); + complete = false; + } else { + width = readU32be(data, 0); + height = readU32be(data, 4); + } + sawHeader = true; + } else if (type === "IDAT") { + sawImageData = true; + } else if (type === "IEND") { + if (length !== 0) { + collector.warn("PNG IEND chunk is not empty."); + complete = false; + } + sawEnd = true; + offset = end + 4; + break; + } else if (type === "acTL" || type === "fcTL" || type === "fdAT") { + animated = true; + blocks.push({ kind: type, offset: dataOffset, length }); + collector.add({ + category: "technical", + risk: "context", + source: "PNG", + label: "APNG animation", + value: `${type} chunk (${length} bytes)`, + offset: dataOffset, + length, + }); + } else if (isMetadataChunk(type)) { + if (length > limits.maxMetadataBlockBytes) { + collector.warn(`PNG ${type} metadata exceeds the block limit.`); + complete = false; + } else { + blocks.push({ kind: type, offset: dataOffset, length }); + const result = scanPngMetadata( + type, + data, + dataOffset, + collector, + limits, + ); + if (result.orientation !== undefined) orientation = result.orientation; + complete &&= result.complete; + } + } else if (type[1] === type[1]?.toLowerCase()) { + blocks.push({ kind: type, offset: dataOffset, length }); + collector.add({ + category: type === "caBX" ? "provenance" : "unknown", + risk: "context", + source: "PNG", + label: + type === "caBX" ? "C2PA provenance chunk" : `Private chunk ${type}`, + value: `${length} bytes`, + offset: dataOffset, + length, + }); + } + offset = end + 4; + } + if (!sawEnd) { + collector.warn("PNG IEND chunk was not found."); + complete = false; + } else if (offset < bytes.byteLength) { + const trailing = bytes.byteLength - offset; + blocks.push({ kind: "trailing-data", offset, length: trailing }); + collector.add({ + category: "unknown", + risk: "sensitive", + source: "PNG", + label: "Trailing data", + value: `${trailing} bytes after IEND`, + offset, + length: trailing, + }); + } + if (!sawHeader) { + collector.warn("PNG IHDR chunk was not found."); + complete = false; + } + if (!sawImageData) { + collector.warn("PNG IDAT image data was not found."); + complete = false; + } + return { + width, + height, + orientation, + animated, + multiImage: false, + complete, + blocks, + }; +} + +function scanPngMetadata( + type: string, + data: Uint8Array, + offset: number, + collector: FindingCollector, + limits: Readonly, +): { orientation?: number; complete: boolean } { + try { + if (type === "eXIf") { + const result = scanTiff(data, "PNG eXIf", offset, collector, limits); + return { orientation: result.orientation, complete: result.complete }; + } + if (type === "tEXt") { + const separator = data.indexOf(0); + const keyword = decodeLatin( + data.subarray(0, separator < 0 ? data.length : separator), + ); + const value = + separator < 0 ? "" : decodeLatin(data.subarray(separator + 1)); + addPngText(keyword, value, type, offset, data.byteLength, collector); + } else if (type === "zTXt") { + const separator = data.indexOf(0); + if (separator < 0 || data[separator + 1] !== 0) + throw new SyntaxError("invalid zTXt header"); + const keyword = decodeLatin(data.subarray(0, separator)); + const inflated = inflateZlibBounded( + data.subarray(separator + 2), + limits.maxInflatedMetadataBytes, + ); + addPngText( + keyword, + decodeLatin(inflated), + type, + offset, + data.byteLength, + collector, + ); + } else if (type === "iTXt") { + const parsed = parseInternationalText( + data, + limits.maxInflatedMetadataBytes, + ); + addPngText( + parsed.keyword, + parsed.text, + type, + offset, + data.byteLength, + collector, + ); + } else if (type === "iCCP") { + const separator = data.indexOf(0); + if (separator < 0 || data[separator + 1] !== 0) + throw new SyntaxError("invalid iCCP header"); + const profile = inflateZlibBounded( + data.subarray(separator + 2), + limits.maxInflatedMetadataBytes, + ); + collector.add({ + category: "colour-profile", + risk: "technical", + source: "PNG iCCP", + label: "ICC profile", + value: `${decodeLatin(data.subarray(0, separator)) || "unnamed"}; ${profile.byteLength} bytes inflated`, + offset, + length: data.byteLength, + }); + } else if (type === "pHYs") { + collector.add({ + category: "technical", + risk: "technical", + source: "PNG pHYs", + label: "Pixel density", + value: `${readU32be(data, 0)}×${readU32be(data, 4)} per ${data[8] === 1 ? "metre" : "unknown unit"}`, + offset, + length: data.byteLength, + }); + } else if (type === "tIME" && data.byteLength === 7) { + collector.add({ + category: "timestamp", + risk: "sensitive", + source: "PNG tIME", + label: "Last modification time", + value: `${readU16be(data, 0)}-${pad(data[2])}-${pad(data[3])} ${pad(data[4])}:${pad(data[5])}:${pad(data[6])} UTC-like fields`, + offset, + length: data.byteLength, + }); + } else if (type === "caBX") { + collector.add({ + category: "provenance", + risk: "context", + source: "PNG caBX", + label: "C2PA provenance data", + value: `${data.byteLength} bytes; re-encoding will remove or invalidate this provenance`, + offset, + length: data.byteLength, + }); + } + return { complete: true }; + } catch (error) { + collector.warn( + `PNG ${type} metadata could not be fully read: ${error instanceof Error ? error.message : "unknown error"}.`, + ); + return { complete: false }; + } +} + +function addPngText( + keyword: string, + value: string, + type: string, + offset: number, + length: number, + collector: FindingCollector, +): void { + if (/xmp/iu.test(keyword) || /<\?xpacket|= data.byteLength) + throw new SyntaxError("invalid iTXt header"); + const compressed = data[first + 1] === 1; + if ((data[first + 1] !== 0 && !compressed) || data[first + 2] !== 0) + throw new SyntaxError("unsupported iTXt compression"); + const languageEnd = data.indexOf(0, first + 3); + if (languageEnd < 0) throw new SyntaxError("truncated iTXt language tag"); + const translatedEnd = data.indexOf(0, languageEnd + 1); + if (translatedEnd < 0) + throw new SyntaxError("truncated iTXt translated keyword"); + const payload = data.subarray(translatedEnd + 1); + return { + keyword: decodeLatin(data.subarray(0, first)), + text: decodeMetadataText( + compressed ? inflateZlibBounded(payload, maximumInflatedBytes) : payload, + ), + }; +} + +function isMetadataChunk(type: string): boolean { + return [ + "tEXt", + "zTXt", + "iTXt", + "eXIf", + "iCCP", + "pHYs", + "tIME", + "caBX", + ].includes(type); +} + +function readU32be(bytes: Uint8Array, offset: number): number { + return ( + (bytes[offset] ?? 0) * 0x1000000 + + ((bytes[offset + 1] ?? 0) << 16) + + ((bytes[offset + 2] ?? 0) << 8) + + (bytes[offset + 3] ?? 0) + ); +} + +function readU16be(bytes: Uint8Array, offset: number): number { + return ((bytes[offset] ?? 0) << 8) | (bytes[offset + 1] ?? 0); +} + +function ascii(bytes: Uint8Array, offset: number, length: number): string { + let value = ""; + for ( + let index = 0; + index < length && offset + index < bytes.length; + index += 1 + ) + value += String.fromCharCode(bytes[offset + index] ?? 0); + return value; +} + +function decodeLatin(bytes: Uint8Array): string { + return new TextDecoder("latin1", { fatal: false }).decode(bytes); +} + +function pad(value: number | undefined): string { + return String(value ?? 0).padStart(2, "0"); +} diff --git a/src/privacy/sanitize.ts b/src/privacy/sanitize.ts new file mode 100644 index 0000000..771b74c --- /dev/null +++ b/src/privacy/sanitize.ts @@ -0,0 +1,435 @@ +import { + digestHex, + sanitizeDownloadFilename, +} from "@add-ideas/toolbox-helpers"; + +import type { + ImageScanResult, + MetadataFinding, + PixelComparison, + SanitizedAsset, + SanitizationReport, +} from "./model"; +import { scanImageBytes } from "./scanner"; + +export interface SanitizeOptions { + jpegQuality?: number; + webpQuality?: number; + signal?: AbortSignal; +} + +export async function sanitizeStaticImage( + file: File, + source: ImageScanResult, + options: SanitizeOptions = {}, +): Promise { + if (!source.cleanable) + throw new TypeError( + `${source.name} is not a supported static clean-copy input.`, + ); + if (source.coverage.projectScanner !== "complete") + throw new TypeError("The source project scan is not complete."); + if (file.size !== source.size || file.name !== source.name) + throw new TypeError( + "The selected source file no longer matches its scan result.", + ); + throwIfAborted(options.signal); + await verifySourceHash(file, source); + throwIfAborted(options.signal); + const mime = outputMime(source.identity.detectedKind); + const decoded = await decodeDrawable(file, source, options.signal); + const canvas = document.createElement("canvas"); + canvas.width = decoded.outputWidth; + canvas.height = decoded.outputHeight; + const context = canvas.getContext("2d", { + alpha: true, + colorSpace: "srgb", + willReadFrequently: false, + }); + if (!context) throw new Error("The browser did not provide a 2D canvas."); + context.save(); + applyOrientationTransform( + context, + decoded.orientationToApply, + decoded.rawWidth, + decoded.rawHeight, + ); + context.drawImage(decoded.drawable, 0, 0); + context.restore(); + decoded.close(); + throwIfAborted(options.signal); + const sourceSample = await sampleDigest(canvas); + const quality = + mime === "image/jpeg" + ? boundedQuality(options.jpegQuality ?? 0.92) + : mime === "image/webp" + ? boundedQuality(options.webpQuality ?? 0.92) + : undefined; + const blob = await canvasToBlob(canvas, mime, quality); + if (blob.type !== mime) + throw new Error( + `This browser encoded ${blob.type || "an unknown format"} instead of ${mime}.`, + ); + throwIfAborted(options.signal); + const outputBytes = await blob.arrayBuffer(); + const outputName = cleanOutputName( + source.safeName, + source.identity.detectedKind, + ); + const outputScan = await scanImageBytes({ + id: `${source.id}-clean`, + name: outputName, + claimedType: mime, + size: outputBytes.byteLength, + lastModified: 0, + bytes: outputBytes, + }); + const outputSample = await sampleBlobDigest(blob); + const pixelComparison: PixelComparison = { + method: "oriented-256px-sample", + sourceDigest: sourceSample, + outputDigest: outputSample, + identical: sourceSample === outputSample, + note: + mime === "image/png" + ? "The decoded, orientation-normalized sample should normally be identical." + : "JPEG and lossy WebP encoding may change decoded sample pixels even when the visible image is preserved.", + }; + const report = buildSanitizationReport( + source, + outputScan, + outputName, + mime, + blob.size, + pixelComparison, + ); + return { blob, report }; +} + +export function buildSanitizationReport( + source: ImageScanResult, + output: ImageScanResult, + outputName: string, + outputType: string, + outputBytes: number, + pixelComparison: PixelComparison, +): SanitizationReport { + const outputKeys = new Set(output.findings.map(findingSignature)); + const sourceKeys = new Set(source.findings.map(findingSignature)); + const removed = source.findings.filter( + (finding) => !outputKeys.has(findingSignature(finding)), + ); + const preserved = source.findings.filter((finding) => + outputKeys.has(findingSignature(finding)), + ); + const generated = output.findings.filter( + (finding) => !sourceKeys.has(findingSignature(finding)), + ); + const unsupported: string[] = []; + const incomplete: string[] = []; + if (source.coverage.projectScanner !== "complete") + incomplete.push( + "The source project scanner did not reach complete coverage.", + ); + if (source.coverage.secondaryScanner !== "complete") + incomplete.push( + `The source secondary scanner status was ${source.coverage.secondaryScanner}.`, + ); + if (output.coverage.projectScanner !== "complete") + incomplete.push( + "The output project scanner did not reach complete coverage.", + ); + if (output.coverage.secondaryScanner !== "complete") + incomplete.push( + `The output secondary scanner status was ${output.coverage.secondaryScanner}.`, + ); + if (source.findings.some((finding) => finding.category === "provenance")) + unsupported.push( + "Source provenance/signature data was removed or invalidated; authenticity cannot be carried through pixel re-encoding.", + ); + const dimensionsMatch = + source.width === undefined || + source.height === undefined || + (output.width === expectedWidth(source) && + output.height === expectedHeight(source)); + if (!dimensionsMatch) + incomplete.push( + "Output dimensions do not match the expected oriented dimensions.", + ); + const orientationNormalized = + (output.orientation === undefined || output.orientation === 1) && + dimensionsMatch; + if (!orientationNormalized) + incomplete.push("Output orientation was not normalized to pixel order."); + if (output.identity.typeMatch !== "match") + incomplete.push("Output type, filename, or detected bytes do not agree."); + if (outputType === "image/png" && !pixelComparison.identical) + incomplete.push( + "Lossless PNG output did not preserve the decoded pixel sample.", + ); + const unsafeOutput = output.findings.filter( + (finding) => + finding.risk === "sensitive" || + finding.category === "comment" || + finding.category === "provenance", + ); + const unexpectedBlocks = findUnexpectedOutputBlocks(output); + if (unexpectedBlocks.length > 0) + incomplete.push( + `Output contains unexpected metadata blocks: ${unexpectedBlocks.join(", ")}.`, + ); + const failed = + output.coverage.projectScanner !== "complete" || + unsafeOutput.length > 0 || + output.animated || + output.multiImage || + !orientationNormalized || + output.identity.typeMatch !== "match" || + (outputType === "image/png" && !pixelComparison.identical); + const warning = + incomplete.length > 0 || + output.coverage.secondaryScanner !== "complete" || + unsupported.length > 0; + const status = failed ? "failed" : warning ? "warning" : "verified"; + return { + sourceId: source.id, + sourceName: source.name, + outputName, + outputType, + sourceSha256: source.sha256, + outputSha256: output.sha256, + sourceBytes: source.size, + outputBytes, + sourceDimensions: + source.width !== undefined && source.height !== undefined + ? { width: source.width, height: source.height } + : undefined, + outputDimensions: + output.width !== undefined && output.height !== undefined + ? { width: output.width, height: output.height } + : undefined, + orientationNormalized, + removed, + preserved, + generated, + unsupported, + incomplete, + outputScan: output, + pixelComparison, + status, + summary: + status === "verified" + ? "The pixel re-encode completed and both bounded output scanners found no sensitive metadata." + : status === "warning" + ? "The pixel re-encode completed, but one or more verification limits require review." + : "The output did not pass the mandatory metadata verification gate.", + disclaimer: + "This report is not an anonymity guarantee. Visible faces or text, steganography, invisible watermarks, reverse-image matching, sidecars, filesystem records, and cloud copies are outside this tool's checks.", + }; +} + +async function verifySourceHash( + file: File, + source: ImageScanResult, +): Promise { + const bytes = new Uint8Array(await file.arrayBuffer()); + const currentHash = await digestHex(bytes, "SHA-256", source.size); + if (currentHash !== source.sha256) + throw new TypeError( + "The selected source bytes no longer match their scan hash.", + ); +} + +function findUnexpectedOutputBlocks(output: ImageScanResult): string[] { + const allowed = + output.identity.detectedKind === "jpeg" + ? new Set(["APP0", "APP2"]) + : output.identity.detectedKind === "png" + ? new Set(["iCCP", "pHYs"]) + : output.identity.detectedKind === "webp" + ? new Set(["ICCP"]) + : new Set(); + return [...new Set(output.blocks.map((block) => block.kind))].filter( + (kind) => !allowed.has(kind), + ); +} + +interface DecodedDrawable { + drawable: CanvasImageSource; + rawWidth: number; + rawHeight: number; + outputWidth: number; + outputHeight: number; + orientationToApply: number; + close(): void; +} + +async function decodeDrawable( + file: File, + source: ImageScanResult, + signal?: AbortSignal, +): Promise { + if ("createImageBitmap" in globalThis) { + const bitmap = await createImageBitmap(file, { imageOrientation: "none" }); + throwIfAborted(signal); + const orientation = normalizeOrientation(source.orientation); + const scannerWidth = source.width ?? bitmap.width; + const scannerHeight = source.height ?? bitmap.height; + const browserAlreadyOriented = + swapsAxes(orientation) && + bitmap.width === scannerHeight && + bitmap.height === scannerWidth; + const orientationToApply = browserAlreadyOriented ? 1 : orientation; + return { + drawable: bitmap, + rawWidth: bitmap.width, + rawHeight: bitmap.height, + outputWidth: swapsAxes(orientationToApply) ? bitmap.height : bitmap.width, + outputHeight: swapsAxes(orientationToApply) + ? bitmap.width + : bitmap.height, + orientationToApply, + close: () => bitmap.close(), + }; + } + const url = URL.createObjectURL(file); + try { + const image = new Image(); + image.decoding = "async"; + image.src = url; + await image.decode(); + throwIfAborted(signal); + return { + drawable: image, + rawWidth: image.naturalWidth, + rawHeight: image.naturalHeight, + outputWidth: image.naturalWidth, + outputHeight: image.naturalHeight, + orientationToApply: 1, + close: () => undefined, + }; + } finally { + URL.revokeObjectURL(url); + } +} + +function applyOrientationTransform( + context: CanvasRenderingContext2D, + orientation: number, + width: number, + height: number, +): void { + if (orientation === 2) context.transform(-1, 0, 0, 1, width, 0); + else if (orientation === 3) context.transform(-1, 0, 0, -1, width, height); + else if (orientation === 4) context.transform(1, 0, 0, -1, 0, height); + else if (orientation === 5) context.transform(0, 1, 1, 0, 0, 0); + else if (orientation === 6) context.transform(0, 1, -1, 0, height, 0); + else if (orientation === 7) context.transform(0, -1, -1, 0, height, width); + else if (orientation === 8) context.transform(0, -1, 1, 0, 0, width); +} + +async function sampleDigest(canvas: HTMLCanvasElement): Promise { + const maximum = 256; + const scale = Math.min(1, maximum / canvas.width, maximum / canvas.height); + const width = Math.max(1, Math.round(canvas.width * scale)); + const height = Math.max(1, Math.round(canvas.height * scale)); + const sample = document.createElement("canvas"); + sample.width = width; + sample.height = height; + const context = sample.getContext("2d", { willReadFrequently: true }); + if (!context) + throw new Error("The browser could not create a verification canvas."); + context.drawImage(canvas, 0, 0, width, height); + const pixels = context.getImageData(0, 0, width, height).data; + return digestHex(pixels, "SHA-256", maximum * maximum * 4); +} + +async function sampleBlobDigest(blob: Blob): Promise { + const bitmap = await createImageBitmap(blob, { imageOrientation: "none" }); + try { + const canvas = document.createElement("canvas"); + canvas.width = bitmap.width; + canvas.height = bitmap.height; + const context = canvas.getContext("2d"); + if (!context) + throw new Error("The browser could not decode output pixels."); + context.drawImage(bitmap, 0, 0); + return sampleDigest(canvas); + } finally { + bitmap.close(); + } +} + +function canvasToBlob( + canvas: HTMLCanvasElement, + type: string, + quality?: number, +): Promise { + return new Promise((resolve, reject) => { + canvas.toBlob( + (blob) => { + if (blob) resolve(blob); + else reject(new Error(`The browser could not encode ${type}.`)); + }, + type, + quality, + ); + }); +} + +function outputMime(kind: ImageScanResult["identity"]["detectedKind"]): string { + if (kind === "jpeg") return "image/jpeg"; + if (kind === "png") return "image/png"; + if (kind === "webp") return "image/webp"; + throw new TypeError(`No clean-copy encoder is available for ${kind}.`); +} + +function cleanOutputName( + input: string, + kind: ImageScanResult["identity"]["detectedKind"], +): string { + const extension = kind === "jpeg" ? "jpg" : kind; + const withoutExtension = input.replace(/\.[^.]*$/u, "") || "image"; + return sanitizeDownloadFilename(`${withoutExtension}.clean.${extension}`); +} + +function findingSignature(finding: MetadataFinding): string { + const label = finding.label + .toLowerCase() + .replace(/[^a-z0-9]+/gu, " ") + .trim(); + return `${finding.category}\u0000${label}\u0000${finding.value}`; +} + +function normalizeOrientation(value: number | undefined): number { + return value !== undefined && value >= 1 && value <= 8 ? value : 1; +} + +function swapsAxes(orientation: number): boolean { + return orientation >= 5 && orientation <= 8; +} + +function expectedWidth(scan: ImageScanResult): number | undefined { + if (scan.width === undefined || scan.height === undefined) return undefined; + return swapsAxes(normalizeOrientation(scan.orientation)) + ? scan.height + : scan.width; +} + +function expectedHeight(scan: ImageScanResult): number | undefined { + if (scan.width === undefined || scan.height === undefined) return undefined; + return swapsAxes(normalizeOrientation(scan.orientation)) + ? scan.width + : scan.height; +} + +function boundedQuality(value: number): number { + if (!Number.isFinite(value) || value < 0.5 || value > 1) + throw new RangeError("Image quality must be between 0.5 and 1."); + return value; +} + +function throwIfAborted(signal?: AbortSignal): void { + if (signal?.aborted) + throw new DOMException("Operation cancelled", "AbortError"); +} diff --git a/src/privacy/scan-client.ts b/src/privacy/scan-client.ts new file mode 100644 index 0000000..bcd4db2 --- /dev/null +++ b/src/privacy/scan-client.ts @@ -0,0 +1,112 @@ +import { assertBatchFiles } from "./limits"; +import type { ImageScanResult, ScanInput } from "./model"; +import type { ScanWorkerRequest, ScanWorkerResponse } from "../worker/protocol"; + +export interface ScanProgress { + completed: number; + total: number; + currentName: string; +} + +export async function scanFilesInWorker( + files: readonly File[], + onProgress: (progress: ScanProgress) => void = () => undefined, + signal?: AbortSignal, +): Promise { + assertBatchFiles(files); + throwIfAborted(signal); + const worker = new Worker( + new URL("../worker/scan.worker.ts", import.meta.url), + { + type: "module", + name: "privacy-metadata-scanner", + }, + ); + const cancel = () => worker.terminate(); + signal?.addEventListener("abort", cancel, { once: true }); + const results: ImageScanResult[] = []; + try { + for (let index = 0; index < files.length; index += 1) { + const file = files[index]; + if (!file) continue; + throwIfAborted(signal); + onProgress({ + completed: index, + total: files.length, + currentName: file.name, + }); + const bytes = await file.arrayBuffer(); + throwIfAborted(signal); + const requestId = `scan-${index}-${fileId(file, index)}`; + const input: ScanInput = { + id: fileId(file, index), + name: file.name, + claimedType: file.type, + size: file.size, + lastModified: file.lastModified, + bytes, + }; + results.push( + await scanOne( + worker, + { type: "scan-file", requestId, file: input }, + signal, + ), + ); + onProgress({ + completed: index + 1, + total: files.length, + currentName: file.name, + }); + } + return results; + } finally { + worker.terminate(); + signal?.removeEventListener("abort", cancel); + } +} + +function scanOne( + worker: Worker, + request: ScanWorkerRequest, + signal?: AbortSignal, +): Promise { + return new Promise((resolve, reject) => { + const dispose = () => { + worker.removeEventListener("message", handleMessage); + worker.removeEventListener("error", handleError); + signal?.removeEventListener("abort", handleAbort); + }; + const handleMessage = (event: MessageEvent) => { + const response = event.data; + if (response.requestId !== request.requestId) return; + dispose(); + if (response.type === "scanned") resolve(response.result); + else reject(new Error(response.message)); + }; + const handleError = (event: ErrorEvent) => { + dispose(); + reject(new Error(event.message || "Metadata worker failed.")); + }; + const handleAbort = () => { + dispose(); + reject(new DOMException("Scan cancelled", "AbortError")); + }; + worker.addEventListener("message", handleMessage); + worker.addEventListener("error", handleError); + signal?.addEventListener("abort", handleAbort, { once: true }); + worker.postMessage(request, [request.file.bytes]); + }); +} + +function fileId(file: File, index: number): string { + const safe = file.name + .toLowerCase() + .replace(/[^a-z0-9]+/gu, "-") + .replace(/^-|-$/gu, ""); + return `${index + 1}-${safe || "file"}-${file.size}-${file.lastModified}`; +} + +function throwIfAborted(signal?: AbortSignal): void { + if (signal?.aborted) throw new DOMException("Scan cancelled", "AbortError"); +} diff --git a/src/privacy/scanner.ts b/src/privacy/scanner.ts new file mode 100644 index 0000000..8ae7e0d --- /dev/null +++ b/src/privacy/scanner.ts @@ -0,0 +1,151 @@ +import { + digestHex, + sanitizeDownloadFilename, +} from "@add-ideas/toolbox-helpers"; + +import { inventoryIdentity } from "./detect"; +import { scanWithExifReader } from "./exif-reader-adapter"; +import { FindingCollector } from "./findings"; +import { scanJpeg, type FormatScan } from "./jpeg"; +import { assertLimit, resolveLimits } from "./limits"; +import type { ImageScanResult, PrivacyLimits, ScanInput } from "./model"; +import { scanPng } from "./png"; +import { scanWebp } from "./webp"; + +const EMPTY_FORMAT: FormatScan = Object.freeze({ + animated: false, + multiImage: false, + complete: false, + blocks: [], +}); + +export async function scanImageBytes( + input: ScanInput, + overrides: Partial = {}, +): Promise { + const limits = resolveLimits(overrides); + assertLimit(input.size, limits.maxFileBytes, "File size"); + if (input.bytes.byteLength !== input.size) + throw new RangeError( + `Declared file size ${input.size} does not match ${input.bytes.byteLength} bytes read`, + ); + const bytes = new Uint8Array(input.bytes); + const identity = inventoryIdentity(input.name, input.claimedType, bytes); + const collector = new FindingCollector(limits); + let format: FormatScan = EMPTY_FORMAT; + if (identity.detectedKind === "jpeg") + format = scanJpeg(bytes, collector, limits); + else if (identity.detectedKind === "png") + format = scanPng(bytes, collector, limits); + else if (identity.detectedKind === "webp") + format = scanWebp(bytes, collector, limits); + + const deepSupported = ["jpeg", "png", "webp"].includes(identity.detectedKind); + const secondarySupported = [ + "jpeg", + "png", + "webp", + "gif", + "tiff", + "heic", + "avif", + "jxl", + ].includes(identity.detectedKind); + const secondary = secondarySupported + ? scanWithExifReader(input.bytes, collector, limits) + : { + status: "unsupported" as const, + notes: ["No deep metadata adapter is available for this format."], + }; + const width = format.width ?? secondary.width; + const height = format.height ?? secondary.height; + let dimensionsAllowed = true; + if (width !== undefined && height !== undefined) { + if (width <= 0 || height <= 0) { + collector.warn("Image dimensions are invalid."); + dimensionsAllowed = false; + } else if ( + width > limits.maxEdge || + height > limits.maxEdge || + width * height > limits.maxPixels + ) { + collector.warn( + `Image dimensions ${width}×${height} exceed the ${limits.maxEdge}-pixel edge or ${limits.maxPixels.toLocaleString("en-US")}-pixel processing limit.`, + ); + dimensionsAllowed = false; + } + } else if (deepSupported) { + collector.warn( + "Pixel dimensions could not be established from the container.", + ); + dimensionsAllowed = false; + } + if (identity.typeMatch === "mismatch") + collector.warn( + "The filename or browser-claimed media type does not match the detected bytes.", + ); + if (!deepSupported) + collector.warn( + "This format receives inventory and best-effort secondary inspection only; clean-copy output is unavailable.", + ); + if (format.animated) + collector.warn("Animated images are inspect-only in version 0.1."); + if (format.multiImage) + collector.warn("Multi-image containers are inspect-only in version 0.1."); + + const cleanable = + deepSupported && + format.complete && + !collector.limited && + !format.animated && + !format.multiImage && + dimensionsAllowed; + const sha256 = await digestHex(bytes, "SHA-256", limits.maxFileBytes); + return { + id: input.id, + name: input.name, + safeName: sanitizeDownloadFilename(input.name, "image"), + size: input.size, + lastModified: input.lastModified, + sha256, + identity, + width, + height, + orientation: format.orientation, + animated: format.animated, + multiImage: format.multiImage, + deepSupported, + cleanable, + findings: collector.findings.sort(compareFindings), + blocks: format.blocks, + warnings: collector.warnings, + coverage: { + projectScanner: deepSupported + ? format.complete && !collector.limited + ? "complete" + : "partial" + : "unsupported", + secondaryScanner: + collector.limited && secondary.status === "complete" + ? "partial" + : secondary.status, + notes: collector.limited + ? [ + ...secondary.notes, + "Normalized finding output reached its text limit.", + ] + : secondary.notes, + }, + }; +} + +function compareFindings( + left: ImageScanResult["findings"][number], + right: ImageScanResult["findings"][number], +): number { + return ( + left.category.localeCompare(right.category) || + left.source.localeCompare(right.source) || + left.label.localeCompare(right.label) + ); +} diff --git a/src/privacy/tiff.ts b/src/privacy/tiff.ts new file mode 100644 index 0000000..784c98e --- /dev/null +++ b/src/privacy/tiff.ts @@ -0,0 +1,346 @@ +import { categoryForName, FindingCollector } from "./findings"; +import { scanIptc } from "./iptc"; +import type { PrivacyLimits } from "./model"; +import { scanXmp } from "./xmp"; + +const TYPE_BYTES: Readonly> = Object.freeze({ + 1: 1, + 2: 1, + 3: 2, + 4: 4, + 5: 8, + 7: 1, + 9: 4, + 10: 8, + 11: 4, + 12: 8, + 13: 4, +}); + +const TAG_NAMES: Readonly> = Object.freeze({ + 0x010e: "Image Description", + 0x010f: "Camera Make", + 0x0110: "Camera Model", + 0x0112: "Orientation", + 0x0131: "Software", + 0x0132: "Date/Time", + 0x013b: "Artist", + 0x0201: "JPEG Thumbnail Offset", + 0x0202: "JPEG Thumbnail Length", + 0x02bc: "XMP", + 0x8298: "Copyright", + 0x83bb: "IPTC/NAA", + 0x8769: "Exif IFD", + 0x8825: "GPS IFD", + 0x9003: "Date/Time Original", + 0x9004: "Date/Time Digitized", + 0x927c: "Maker Note", + 0x9286: "User Comment", + 0xa005: "Interoperability IFD", + 0xa420: "Image Unique ID", + 0xa430: "Camera Owner Name", + 0xa431: "Camera Body Serial Number", + 0xa432: "Lens Specification", + 0xa433: "Lens Make", + 0xa434: "Lens Model", + 0xa435: "Lens Serial Number", + 0x9c9b: "Windows Title", + 0x9c9c: "Windows Comment", + 0x9c9d: "Windows Author", + 0x9c9e: "Windows Keywords", + 0x9c9f: "Windows Subject", + 0x8773: "ICC Profile", +}); + +const GPS_NAMES: Readonly> = Object.freeze({ + 0: "GPS Version", + 1: "GPS Latitude Reference", + 2: "GPS Latitude", + 3: "GPS Longitude Reference", + 4: "GPS Longitude", + 5: "GPS Altitude Reference", + 6: "GPS Altitude", + 7: "GPS Time Stamp", + 11: "GPS Dilution of Precision", + 12: "GPS Speed Reference", + 13: "GPS Speed", + 16: "GPS Direction Reference", + 17: "GPS Direction", + 18: "GPS Map Datum", + 27: "GPS Processing Method", + 28: "GPS Area Information", + 29: "GPS Date Stamp", + 31: "GPS Horizontal Positioning Error", +}); + +export interface TiffScan { + orientation?: number; + complete: boolean; +} + +interface IfdTask { + offset: number; + role: "main" | "exif" | "gps" | "interop" | "thumbnail"; + depth: number; +} + +export function scanTiff( + bytes: Uint8Array, + source: string, + baseOffset: number, + collector: FindingCollector, + limits: Readonly, +): TiffScan { + if (bytes.byteLength < 8) { + collector.warn(`${source} TIFF data is truncated.`); + return { complete: false }; + } + const littleEndian = bytes[0] === 0x49 && bytes[1] === 0x49; + const bigEndian = bytes[0] === 0x4d && bytes[1] === 0x4d; + if (!littleEndian && !bigEndian) { + collector.warn(`${source} TIFF byte order is invalid.`); + return { complete: false }; + } + const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength); + const u16 = (offset: number) => view.getUint16(offset, littleEndian); + const u32 = (offset: number) => view.getUint32(offset, littleEndian); + if (u16(2) !== 42) { + collector.warn(`${source} TIFF magic is unsupported.`); + return { complete: false }; + } + const tasks: IfdTask[] = [{ offset: u32(4), role: "main", depth: 0 }]; + const visited = new Set(); + let totalEntries = 0; + let orientation: number | undefined; + let complete = true; + + while (tasks.length > 0) { + const task = tasks.pop(); + if (!task) break; + if (task.depth > limits.maxTiffDepth) { + collector.warn( + `${source} TIFF IFD depth exceeded ${limits.maxTiffDepth}.`, + ); + complete = false; + continue; + } + if (task.offset === 0) continue; + if (visited.has(task.offset)) { + collector.warn( + `${source} TIFF IFD cycle was stopped at offset ${task.offset}.`, + ); + complete = false; + continue; + } + visited.add(task.offset); + if (task.offset < 8 || task.offset + 2 > bytes.byteLength) { + collector.warn( + `${source} TIFF IFD offset is outside the metadata block.`, + ); + complete = false; + continue; + } + const count = u16(task.offset); + totalEntries += count; + if (totalEntries > limits.maxTiffEntries) { + collector.warn( + `${source} TIFF entry count exceeded ${limits.maxTiffEntries}.`, + ); + complete = false; + break; + } + const tableEnd = task.offset + 2 + count * 12; + if (tableEnd + 4 > bytes.byteLength) { + collector.warn(`${source} TIFF IFD entry table is truncated.`); + complete = false; + continue; + } + for (let index = 0; index < count; index += 1) { + const entryOffset = task.offset + 2 + index * 12; + const tag = u16(entryOffset); + const type = u16(entryOffset + 2); + const itemCount = u32(entryOffset + 4); + const unit = TYPE_BYTES[type]; + if (!unit) continue; + const byteLength = itemCount * unit; + if ( + !Number.isSafeInteger(byteLength) || + byteLength > limits.maxMetadataBlockBytes + ) { + collector.warn( + `${source} TIFF tag 0x${tag.toString(16)} is oversized.`, + ); + complete = false; + continue; + } + const dataOffset = + byteLength <= 4 ? entryOffset + 8 : u32(entryOffset + 8); + if (dataOffset + byteLength > bytes.byteLength) { + collector.warn( + `${source} TIFF tag 0x${tag.toString(16)} points outside its block.`, + ); + complete = false; + continue; + } + const data = bytes.subarray(dataOffset, dataOffset + byteLength); + const values = readValues( + view, + dataOffset, + itemCount, + type, + littleEndian, + ); + const first = values[0]; + if (tag === 0x8769 || tag === 0x8825 || tag === 0xa005) { + if (typeof first === "number") { + tasks.push({ + offset: first, + role: tag === 0x8825 ? "gps" : tag === 0xa005 ? "interop" : "exif", + depth: task.depth + 1, + }); + } + continue; + } + if (tag === 0x014a) { + for (const value of values) + if (typeof value === "number") + tasks.push({ offset: value, role: "main", depth: task.depth + 1 }); + continue; + } + if (tag === 0x0112 && typeof first === "number") orientation = first; + if (tag === 0x02bc) { + scanXmp(data, `${source} XMP tag`, baseOffset + dataOffset, collector); + continue; + } + if (tag === 0x83bb) { + scanIptc( + data, + `${source} IPTC tag`, + baseOffset + dataOffset, + collector, + ); + continue; + } + const label = + task.role === "gps" + ? (GPS_NAMES[tag] ?? `GPS tag 0x${tag.toString(16)}`) + : TAG_NAMES[tag]; + if (!label) continue; + const classification = + task.role === "gps" + ? ({ category: "location", risk: "sensitive" } as const) + : categoryForName(label); + collector.add({ + ...classification, + source, + label, + value: + tag === 0x0112 && typeof first === "number" + ? orientationName(first) + : displayTiffValue(data, values, type, tag), + offset: baseOffset + dataOffset, + length: byteLength, + }); + } + const next = u32(tableEnd); + if (next !== 0) + tasks.push({ + offset: next, + role: task.role === "main" ? "thumbnail" : task.role, + depth: task.depth + 1, + }); + } + return { orientation, complete }; +} + +function readValues( + view: DataView, + offset: number, + count: number, + type: number, + littleEndian: boolean, +): Array { + if (type === 2) { + const bytes = new Uint8Array(view.buffer, view.byteOffset + offset, count); + return [ + stripTerminalNulls( + new TextDecoder("utf-8", { fatal: false }).decode(bytes), + ), + ]; + } + const result: Array = []; + const maximum = Math.min(count, 128); + for (let index = 0; index < maximum; index += 1) { + const itemOffset = + offset + + index * + (type === 3 + ? 2 + : type === 4 || type === 9 || type === 11 + ? 4 + : type === 5 || type === 10 || type === 12 + ? 8 + : 1); + if (type === 1 || type === 7) result.push(view.getUint8(itemOffset)); + else if (type === 3) result.push(view.getUint16(itemOffset, littleEndian)); + else if (type === 4 || type === 13) + result.push(view.getUint32(itemOffset, littleEndian)); + else if (type === 9) result.push(view.getInt32(itemOffset, littleEndian)); + else if (type === 11) + result.push(view.getFloat32(itemOffset, littleEndian)); + else if (type === 12) + result.push(view.getFloat64(itemOffset, littleEndian)); + else if (type === 5 || type === 10) { + const numerator = + type === 5 + ? view.getUint32(itemOffset, littleEndian) + : view.getInt32(itemOffset, littleEndian); + const denominator = + type === 5 + ? view.getUint32(itemOffset + 4, littleEndian) + : view.getInt32(itemOffset + 4, littleEndian); + result.push( + denominator === 0 ? `${numerator}/0` : numerator / denominator, + ); + } + } + if (count > maximum) result.push(`… ${count - maximum} more values`); + return result; +} + +function displayTiffValue( + data: Uint8Array, + values: Array, + type: number, + tag: number, +): string { + if (type === 2) return String(values[0] ?? ""); + if (tag >= 0x9c9b && tag <= 0x9c9f && data.byteLength % 2 === 0) + return stripTerminalNulls( + new TextDecoder("utf-16le", { fatal: false }).decode(data), + ); + if (tag === 0x927c || tag === 0x8773) return `${data.byteLength} bytes`; + return values.join(", "); +} + +function stripTerminalNulls(value: string): string { + let end = value.length; + while (end > 0 && value.charCodeAt(end - 1) === 0) end -= 1; + return value.slice(0, end); +} + +function orientationName(value: number): string { + return ( + [ + "Unknown", + "1 — normal", + "2 — mirrored horizontally", + "3 — rotated 180°", + "4 — mirrored vertically", + "5 — mirrored then rotated 90° clockwise", + "6 — rotated 90° clockwise", + "7 — mirrored then rotated 90° counter-clockwise", + "8 — rotated 90° counter-clockwise", + ][value] ?? `${value} — invalid orientation` + ); +} diff --git a/src/privacy/webp.ts b/src/privacy/webp.ts new file mode 100644 index 0000000..1bed275 --- /dev/null +++ b/src/privacy/webp.ts @@ -0,0 +1,189 @@ +import { FindingCollector } from "./findings"; +import type { MetadataBlock, PrivacyLimits } from "./model"; +import type { FormatScan } from "./jpeg"; +import { scanTiff } from "./tiff"; +import { scanXmp } from "./xmp"; + +export function scanWebp( + bytes: Uint8Array, + collector: FindingCollector, + limits: Readonly, +): FormatScan { + const blocks: MetadataBlock[] = []; + const declared = readU32le(bytes, 4) + 8; + let complete = declared === bytes.byteLength; + if (declared > bytes.byteLength || declared < 12) { + collector.warn("WebP RIFF size is invalid or truncated."); + complete = false; + } else if (declared < bytes.byteLength) { + const trailing = bytes.byteLength - declared; + blocks.push({ kind: "trailing-data", offset: declared, length: trailing }); + collector.add({ + category: "unknown", + risk: "sensitive", + source: "WebP", + label: "Trailing data", + value: `${trailing} bytes after the declared RIFF container`, + offset: declared, + length: trailing, + }); + } + const containerEnd = Math.min(declared, bytes.byteLength); + let offset = 12; + let chunks = 0; + let width: number | undefined; + let height: number | undefined; + let orientation: number | undefined; + let animated = false; + let sawImageData = false; + while (offset + 8 <= containerEnd) { + const type = ascii(bytes, offset, 4); + const length = readU32le(bytes, offset + 4); + const dataOffset = offset + 8; + const end = dataOffset + length; + if (!/^[\x20-\x7e]{4}$/u.test(type) || end > containerEnd) { + collector.warn(`WebP chunk at byte ${offset} is malformed or truncated.`); + complete = false; + break; + } + chunks += 1; + if (chunks > limits.maxMetadataBlocks) { + collector.warn(`WebP chunk count exceeded ${limits.maxMetadataBlocks}.`); + complete = false; + break; + } + const data = bytes.subarray(dataOffset, end); + if (type === "VP8X" && data.byteLength >= 10) { + animated ||= ((data[0] ?? 0) & 0x02) !== 0; + width = 1 + readU24le(data, 4); + height = 1 + readU24le(data, 7); + } else if (type === "VP8 " && data.byteLength >= 10) { + sawImageData = true; + if (data[3] === 0x9d && data[4] === 0x01 && data[5] === 0x2a) { + width = readU16le(data, 6) & 0x3fff; + height = readU16le(data, 8) & 0x3fff; + } + } else if (type === "VP8L" && data.byteLength >= 5 && data[0] === 0x2f) { + sawImageData = true; + const bits = readU32le(data, 1); + width = 1 + (bits & 0x3fff); + height = 1 + ((bits >>> 14) & 0x3fff); + } else if (type === "ANIM" || type === "ANMF") { + animated = true; + blocks.push({ kind: type, offset: dataOffset, length }); + } else if (["EXIF", "XMP ", "ICCP", "META"].includes(type)) { + if (length > limits.maxMetadataBlockBytes) { + collector.warn(`WebP ${type.trim()} metadata exceeds the block limit.`); + complete = false; + } else { + blocks.push({ kind: type.trim(), offset: dataOffset, length }); + if (type === "EXIF") { + const prefix = ascii(data, 0, 6) === "Exif\u0000\u0000" ? 6 : 0; + const result = scanTiff( + data.subarray(prefix), + "WebP EXIF", + dataOffset + prefix, + collector, + limits, + ); + orientation = result.orientation; + complete &&= result.complete; + } else if (type === "XMP ") { + scanXmp(data, "WebP XMP", dataOffset, collector); + } else if (type === "ICCP") { + collector.add({ + category: "colour-profile", + risk: "technical", + source: "WebP ICCP", + label: "ICC profile", + value: `${length} bytes`, + offset: dataOffset, + length, + }); + } else { + collector.add({ + category: "unknown", + risk: "context", + source: "WebP META", + label: "Generic metadata chunk", + value: `${length} bytes`, + offset: dataOffset, + length, + }); + } + } + } else if (type === "ALPH") { + // Pixel alpha data, not metadata. + } else if (!["VP8X", "VP8 ", "VP8L", "ANIM", "ANMF"].includes(type)) { + const lower = ascii( + data, + 0, + Math.min(data.byteLength, 4096), + ).toLowerCase(); + const provenance = lower.includes("c2pa") || lower.includes("jumb"); + blocks.push({ + kind: type.trim() || "unknown", + offset: dataOffset, + length, + }); + collector.add({ + category: provenance ? "provenance" : "unknown", + risk: "context", + source: "WebP", + label: provenance + ? "Unrecognized provenance chunk" + : `Unrecognized ${type} chunk`, + value: `${length} bytes`, + offset: dataOffset, + length, + }); + } + offset = end + (length % 2); + } + if (offset !== containerEnd) { + collector.warn("WebP chunk padding or RIFF boundary is inconsistent."); + complete = false; + } + if (!sawImageData && !animated) { + collector.warn("WebP pixel data was not found."); + complete = false; + } + return { + width, + height, + orientation, + animated, + multiImage: false, + complete, + blocks, + }; +} + +function ascii(bytes: Uint8Array, offset: number, length: number): string { + if (offset < 0 || offset + length > bytes.byteLength) return ""; + let value = ""; + for (let index = 0; index < length; index += 1) + value += String.fromCharCode(bytes[offset + index] ?? 0); + return value; +} + +function readU16le(bytes: Uint8Array, offset: number): number { + return (bytes[offset] ?? 0) | ((bytes[offset + 1] ?? 0) << 8); +} + +function readU24le(bytes: Uint8Array, offset: number): number { + return ( + (bytes[offset] ?? 0) | + ((bytes[offset + 1] ?? 0) << 8) | + ((bytes[offset + 2] ?? 0) << 16) + ); +} + +function readU32le(bytes: Uint8Array, offset: number): number { + return ( + (bytes[offset] ?? 0) + + (bytes[offset + 1] ?? 0) * 0x100 + + (bytes[offset + 2] ?? 0) * 0x10000 + + (bytes[offset + 3] ?? 0) * 0x1000000 + ); +} diff --git a/src/privacy/xmp.ts b/src/privacy/xmp.ts new file mode 100644 index 0000000..6bd78ee --- /dev/null +++ b/src/privacy/xmp.ts @@ -0,0 +1,94 @@ +import { categoryForName, FindingCollector } from "./findings"; + +const NAMED_VALUES = + /(?:<|\s)([A-Za-z_][\w.-]*:[A-Za-z_][\w.-]*)(?:\s*=\s*["']([^"']*)["']|[^>]*>([^<]{1,65536})<)/gu; + +export function scanXmp( + input: Uint8Array | string, + source: string, + offset: number | undefined, + collector: FindingCollector, +): void { + const raw = typeof input === "string" ? input : decodeMetadataText(input); + if (!raw.trim()) return; + let matched = 0; + for (const match of raw.matchAll(NAMED_VALUES)) { + const name = match[1] ?? "XMP value"; + const value = decodeXmlEntities(match[2] ?? match[3] ?? ""); + if (!value.trim()) continue; + const classification = categoryForName(name); + if ( + classification.category !== "unknown" || + /(?:xmp|rdf|dc|exif|photoshop|tiff):/iu.test(name) + ) { + collector.add({ + ...classification, + source, + label: name, + value, + offset, + length: typeof input === "string" ? input.length : input.byteLength, + }); + matched += 1; + } + } + for (const token of ["c2pa", "jumbf", "provenance", "manifest"]) { + if (raw.toLowerCase().includes(token)) { + collector.add({ + category: "provenance", + risk: "context", + source, + label: "Provenance marker", + value: token.toUpperCase(), + offset, + length: typeof input === "string" ? input.length : input.byteLength, + }); + } + } + collector.add({ + category: matched > 0 ? "technical" : "unknown", + risk: matched > 0 ? "technical" : "context", + source, + label: "Raw XMP packet", + value: raw, + offset, + length: typeof input === "string" ? input.length : input.byteLength, + }); +} + +export function decodeMetadataText(bytes: Uint8Array): string { + if (bytes.byteLength >= 2 && bytes[0] === 0xff && bytes[1] === 0xfe) + return new TextDecoder("utf-16le", { fatal: false }).decode( + bytes.subarray(2), + ); + if (bytes.byteLength >= 2 && bytes[0] === 0xfe && bytes[1] === 0xff) + return new TextDecoder("utf-16be", { fatal: false }).decode( + bytes.subarray(2), + ); + return new TextDecoder("utf-8", { fatal: false }).decode(bytes); +} + +function decodeXmlEntities(value: string): string { + return value.replace( + /&(?:amp|lt|gt|quot|apos|#\d+|#x[\da-f]+);/giu, + (entity) => { + if (entity === "&") return "&"; + if (entity === "<") return "<"; + if (entity === ">") return ">"; + if (entity === """) return '"'; + if (entity === "'") return "'"; + const hex = /^&#x([\da-f]+);$/iu.exec(entity); + const decimal = /^&#(\d+);$/u.exec(entity); + const codePoint = hex + ? Number.parseInt(hex[1] ?? "", 16) + : decimal + ? Number.parseInt(decimal[1] ?? "", 10) + : Number.NaN; + return Number.isInteger(codePoint) && + codePoint >= 0 && + codePoint <= 0x10ffff + ? String.fromCodePoint(codePoint) + : entity; + }, + ); +} diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..33fa604 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,757 @@ +:root { + --privacy-purple: #5946bc; + --privacy-teal: #147d72; + --privacy-warning: #9a5a08; + --privacy-success: #147057; + --toolbox-background: #f6f7fb; + --toolbox-surface: #ffffff; + --toolbox-surface-soft: #eff1f7; + --toolbox-text: #202332; + --toolbox-muted: #656b7d; + --toolbox-border: #d9dce7; + --toolbox-accent: var(--privacy-purple); + --toolbox-accent-hover: #493caf; + --toolbox-accent-soft: #ece9ff; + --toolbox-accent-contrast: #ffffff; + --toolbox-focus: var(--privacy-teal); + --toolbox-danger: #b42342; +} + +* { + box-sizing: border-box; +} + +html { + min-width: 20rem; + min-height: 100%; + background: var(--toolbox-background); + scrollbar-gutter: stable; +} + +body { + min-width: 20rem; + min-height: 100vh; + margin: 0; + background: var(--toolbox-background); + color: var(--toolbox-text); + font-family: + Inter, + ui-sans-serif, + system-ui, + -apple-system, + BlinkMacSystemFont, + "Segoe UI", + sans-serif; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; +} + +#root { + min-height: 100vh; +} + +::selection { + background: color-mix(in srgb, var(--toolbox-focus) 36%, transparent); +} + +.toolbox-shell__main { + width: min(100%, 90rem); + padding: clamp(0.75rem, 1.8vw, 1.5rem); +} + +:where(button, input, select, textarea) { + font: inherit; +} + +:where(button, .button) { + min-height: 2.55rem; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.4rem; + padding: 0.55rem 0.8rem; + border: 1px solid var(--toolbox-border); + border-radius: 0.65rem; + background: var(--toolbox-surface); + color: var(--toolbox-text); + font-size: 0.8rem; + font-weight: 720; + line-height: 1.2; + cursor: pointer; + touch-action: manipulation; + transition: + border-color 140ms ease, + background-color 140ms ease, + transform 140ms ease; +} + +button:hover:not(:disabled), +.button:hover { + border-color: var(--toolbox-accent); + background: var(--toolbox-surface-soft); +} + +button:active:not(:disabled) { + transform: translateY(1px); +} + +button:disabled { + cursor: not-allowed; + opacity: 0.48; +} + +:where(button, input, select, textarea, summary, a):focus-visible { + outline: 3px solid color-mix(in srgb, var(--toolbox-focus) 42%, transparent); + outline-offset: 2px; +} + +.primary-button { + border-color: var(--toolbox-accent); + background: var(--toolbox-accent); + color: var(--toolbox-accent-contrast); +} + +.primary-button:hover:not(:disabled) { + background: var(--toolbox-accent-hover); +} + +.sr-only { + position: absolute !important; + width: 1px !important; + height: 1px !important; + padding: 0 !important; + margin: -1px !important; + overflow: hidden !important; + clip: rect(0, 0, 0, 0) !important; + white-space: nowrap !important; + border: 0 !important; +} + +.workbench { + display: grid; + gap: 1rem; +} + +.hero, +.panel, +.boundary-note { + border: 1px solid var(--toolbox-border); + border-radius: 0.9rem; + background: var(--toolbox-surface); + box-shadow: + 0 1px 2px rgb(24 30 60 / 4%), + 0 9px 28px rgb(24 30 60 / 3%); +} + +.hero { + display: flex; + justify-content: space-between; + gap: 1rem; + align-items: flex-start; + padding: clamp(1.1rem, 3vw, 2rem); + background: + radial-gradient( + circle at 88% 20%, + color-mix(in srgb, var(--toolbox-focus) 12%, transparent), + transparent 33% + ), + var(--toolbox-surface); +} + +:where(.hero, .panel, .help-dialog, .fatal) :where(h1, h2, h3) { + margin: 0; + color: var(--toolbox-text); + font-weight: 760; + letter-spacing: -0.025em; + line-height: 1.17; +} + +.hero h1 { + font-size: clamp(1.7rem, 3vw, 2.5rem); +} + +.panel h2, +.help-dialog h2 { + font-size: clamp(1.25rem, 2vw, 1.65rem); +} + +.panel h3, +.help-dialog h3 { + font-size: 1rem; +} + +.hero p:not(.eyebrow) { + max-width: 58rem; + margin: 0.55rem 0 0; + color: var(--toolbox-muted); + line-height: 1.55; +} + +.eyebrow { + margin: 0 0 0.3rem; + color: var(--toolbox-accent); + font-size: 0.69rem; + font-weight: 820; + letter-spacing: 0.115em; + text-transform: uppercase; +} + +.privacy-pill, +.status-badge { + flex: 0 0 auto; + display: inline-flex; + align-items: center; + width: max-content; + padding: 0.38rem 0.62rem; + border: 1px solid color-mix(in srgb, var(--toolbox-accent) 25%, transparent); + border-radius: 999px; + background: var(--toolbox-accent-soft); + color: var(--toolbox-accent); + font-size: 0.7rem; + font-weight: 760; + line-height: 1.15; + text-transform: capitalize; +} + +.panel { + min-width: 0; + padding: clamp(0.85rem, 2vw, 1.15rem); +} + +.panel-heading, +.file-card-heading, +.verification-heading { + display: flex; + justify-content: space-between; + gap: 1rem; + align-items: flex-start; +} + +.panel-heading { + margin-bottom: 0.9rem; +} + +.action-heading { + align-items: flex-end; +} + +.muted { + margin: 0.35rem 0 0; + color: var(--toolbox-muted); + font-size: 0.82rem; + line-height: 1.5; +} + +.limit-note { + color: var(--toolbox-muted); + font-size: 0.72rem; + white-space: nowrap; +} + +.drop-zone { + width: 100%; + min-height: 10rem; + flex-direction: column; + padding: 1.25rem; + border: 1.5px dashed + color-mix(in srgb, var(--toolbox-accent) 45%, var(--toolbox-border)); + background: color-mix( + in srgb, + var(--toolbox-accent-soft) 54%, + var(--toolbox-surface) + ); + text-align: center; +} + +.drop-zone > strong { + font-size: 1rem; +} + +.drop-zone > span:last-child { + max-width: 42rem; + color: var(--toolbox-muted); + font-size: 0.76rem; + font-weight: 520; + line-height: 1.5; +} + +.drop-zone.is-dragging { + border-style: solid; + border-color: var(--toolbox-focus); + background: color-mix( + in srgb, + var(--toolbox-focus) 12%, + var(--toolbox-surface) + ); +} + +.drop-icon { + width: 2.6rem; + height: 2.6rem; + display: grid; + place-items: center; + border-radius: 50%; + background: var(--toolbox-accent); + color: var(--toolbox-accent-contrast) !important; + font-size: 1.2rem !important; +} + +.progress { + display: grid; + gap: 0.4rem; + margin-top: 0.8rem; + color: var(--toolbox-muted); + font-size: 0.75rem; +} + +.progress progress { + width: 100%; + height: 0.55rem; + accent-color: var(--toolbox-accent); +} + +.button-row { + display: flex; + align-items: center; + justify-content: flex-end; + flex-wrap: wrap; + gap: 0.5rem; +} + +.inventory-table-wrap { + overflow: auto; + border: 1px solid var(--toolbox-border); + border-radius: 0.72rem; +} + +.inventory-table { + width: 100%; + min-width: 52rem; + border-collapse: collapse; + font-size: 0.77rem; +} + +.inventory-table :where(th, td) { + padding: 0.65rem 0.72rem; + border-bottom: 1px solid var(--toolbox-border); + text-align: left; + vertical-align: middle; +} + +.inventory-table th { + position: sticky; + z-index: 1; + top: 0; + background: var(--toolbox-surface-soft); + color: var(--toolbox-muted); + font-size: 0.68rem; + letter-spacing: 0.04em; + text-transform: uppercase; +} + +.inventory-table tbody tr:last-child td { + border-bottom: 0; +} + +.inventory-table td { + max-width: 20rem; +} + +.inventory-table td > :where(strong, span, code) { + display: block; + overflow-wrap: anywhere; +} + +.inventory-table td > span:not(.status-badge) { + margin-top: 0.25rem; + color: var(--toolbox-muted); + font-size: 0.68rem; +} + +.inventory-table .status-badge { + margin-top: 0.28rem; +} + +.status-badge.is-mismatch, +.status-badge.is-failed { + border-color: color-mix(in srgb, var(--toolbox-danger) 35%, transparent); + background: color-mix( + in srgb, + var(--toolbox-danger) 10%, + var(--toolbox-surface) + ); + color: var(--toolbox-danger); +} + +.status-badge.is-warning, +.status-badge.is-unknown, +.status-badge.is-unclaimed { + border-color: color-mix(in srgb, var(--privacy-warning) 35%, transparent); + background: color-mix( + in srgb, + var(--privacy-warning) 10%, + var(--toolbox-surface) + ); + color: var(--privacy-warning); +} + +.status-badge.is-verified, +.status-badge.is-match { + border-color: color-mix(in srgb, var(--privacy-success) 35%, transparent); + background: color-mix( + in srgb, + var(--privacy-success) 10%, + var(--toolbox-surface) + ); + color: var(--privacy-success); +} + +.file-results { + display: grid; + gap: 1rem; +} + +.file-card { + display: grid; + gap: 0.85rem; +} + +.file-card-heading { + align-items: center; +} + +.hash-line { + max-width: 70rem; + overflow-wrap: anywhere; +} + +.hash-line code, +.finding-list code, +.verification-grid code { + font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; + font-size: 0.74rem; +} + +.warning-list, +.error-message, +.boundary-note { + margin: 0; + padding: 0.72rem 0.86rem; + border-radius: 0.68rem; + font-size: 0.78rem; + line-height: 1.5; +} + +.warning-list { + padding-left: 2rem; + border: 1px solid + color-mix(in srgb, var(--privacy-warning) 32%, var(--toolbox-border)); + background: color-mix( + in srgb, + var(--privacy-warning) 7%, + var(--toolbox-surface) + ); + color: color-mix(in srgb, var(--privacy-warning) 82%, var(--toolbox-text)); +} + +.error-message { + border: 1px solid + color-mix(in srgb, var(--toolbox-danger) 32%, var(--toolbox-border)); + background: color-mix( + in srgb, + var(--toolbox-danger) 7%, + var(--toolbox-surface) + ); + color: var(--toolbox-danger); +} + +.finding-summary { + display: grid; + gap: 0.45rem; +} + +.finding-summary > p { + margin: 0; + color: var(--toolbox-muted); + font-size: 0.8rem; +} + +.finding-summary details, +.verification details { + overflow: hidden; + border: 1px solid var(--toolbox-border); + border-radius: 0.65rem; + background: var(--toolbox-surface); +} + +.finding-summary summary, +.verification summary { + display: flex; + justify-content: space-between; + gap: 0.7rem; + padding: 0.62rem 0.72rem; + background: var(--toolbox-surface-soft); + font-size: 0.77rem; + font-weight: 730; + cursor: pointer; +} + +.finding-list { + display: grid; +} + +.finding-list > div { + min-width: 0; + display: grid; + grid-template-columns: minmax(9rem, 0.32fr) minmax(0, 1fr); + gap: 0.8rem; + padding: 0.62rem 0.72rem; +} + +.finding-list > div + div { + border-top: 1px solid var(--toolbox-border); +} + +.finding-list > div > div { + display: grid; + align-content: start; + gap: 0.2rem; +} + +.finding-list strong { + font-size: 0.75rem; +} + +.finding-list span { + color: var(--toolbox-muted); + font-size: 0.66rem; +} + +.finding-list code { + overflow: auto; + max-height: 12rem; + padding: 0.45rem; + border-radius: 0.4rem; + background: var(--toolbox-surface-soft); + color: var(--toolbox-text); + overflow-wrap: anywhere; + white-space: pre-wrap; +} + +.finding-list .omitted-findings { + margin: 0; + padding: 0.55rem 0.72rem; + border-top: 1px solid var(--toolbox-border); + color: var(--toolbox-muted); + font-size: 0.72rem; +} + +.verification { + display: grid; + gap: 0.8rem; + padding: 0.9rem; + border: 1px solid + color-mix(in srgb, var(--privacy-success) 30%, var(--toolbox-border)); + border-radius: 0.75rem; + background: color-mix( + in srgb, + var(--privacy-success) 5%, + var(--toolbox-surface) + ); +} + +.verification.is-warning { + border-color: color-mix( + in srgb, + var(--privacy-warning) 35%, + var(--toolbox-border) + ); + background: color-mix( + in srgb, + var(--privacy-warning) 5%, + var(--toolbox-surface) + ); +} + +.verification.is-failed { + border-color: color-mix( + in srgb, + var(--toolbox-danger) 35%, + var(--toolbox-border) + ); + background: color-mix( + in srgb, + var(--toolbox-danger) 5%, + var(--toolbox-surface) + ); +} + +.verification-grid { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 0.65rem; + margin: 0; +} + +.verification-grid > div { + min-width: 0; + padding: 0.62rem; + border: 1px solid var(--toolbox-border); + border-radius: 0.58rem; + background: var(--toolbox-surface); +} + +.verification-grid dt { + color: var(--toolbox-muted); + font-size: 0.67rem; + font-weight: 720; +} + +.verification-grid dd { + margin: 0.3rem 0 0; + overflow-wrap: anywhere; + font-size: 0.75rem; +} + +.verification details ul { + margin: 0; + padding: 0.7rem 0.7rem 0.7rem 2rem; + font-size: 0.76rem; +} + +.disclaimer { + margin: 0; + color: var(--toolbox-muted); + font-size: 0.73rem; + line-height: 1.5; +} + +.boundary-note { + border-color: color-mix( + in srgb, + var(--privacy-warning) 30%, + var(--toolbox-border) + ); + background: color-mix( + in srgb, + var(--privacy-warning) 6%, + var(--toolbox-surface) + ); +} + +.help-dialog { + width: min(48rem, calc(100% - 2rem)); + max-height: calc(100vh - 2rem); + padding: clamp(1rem, 2.5vw, 1.4rem); + overflow: auto; + border: 1px solid var(--toolbox-border); + border-radius: 0.9rem; + background: var(--toolbox-surface); + color: var(--toolbox-text); + box-shadow: 0 24px 80px rgb(10 16 38 / 28%); +} + +.help-dialog::backdrop { + background: rgb(20 24 45 / 55%); + backdrop-filter: blur(2px); +} + +.dialog-heading { + display: flex; + justify-content: space-between; + gap: 1rem; + align-items: flex-start; + margin-bottom: 0.85rem; +} + +.dialog-heading button { + width: 2.55rem; + min-width: 2.55rem; + padding: 0; +} + +.help-sections { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 0.75rem; +} + +.help-sections section { + display: grid; + align-content: start; + gap: 0.45rem; + padding: 0.85rem; + border: 1px solid var(--toolbox-border); + border-radius: 0.68rem; + background: var(--toolbox-surface-soft); +} + +.help-sections p { + margin: 0; + color: var(--toolbox-muted); + font-size: 0.8rem; + line-height: 1.55; +} + +.loading, +.fatal { + width: min(100% - 2rem, 60rem); + margin: 2rem auto; + padding: 1rem; +} + +@media (max-width: 64rem) { + .verification-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + +@media (max-width: 48rem) { + .hero, + .panel-heading, + .file-card-heading, + .verification-heading { + flex-direction: column; + } + + .privacy-pill { + order: -1; + } + + .action-heading { + align-items: stretch; + } + + .button-row { + justify-content: flex-start; + } + + .finding-list > div, + .help-sections { + grid-template-columns: 1fr; + } +} + +@media (max-width: 32rem) { + .toolbox-shell__main { + padding: 0.65rem; + } + + .button-row > button { + width: 100%; + } + + .verification-grid { + grid-template-columns: 1fr; + } +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + transition-duration: 0.01ms !important; + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + } +} diff --git a/src/test/setup.ts b/src/test/setup.ts new file mode 100644 index 0000000..e257a0e --- /dev/null +++ b/src/test/setup.ts @@ -0,0 +1,8 @@ +import "@testing-library/jest-dom/vitest"; +import { afterEach } from "vitest"; +import { cleanup } from "@testing-library/react"; + +afterEach(() => { + cleanup(); + globalThis.localStorage?.clear(); +}); diff --git a/src/toolbox/manifest.source.json b/src/toolbox/manifest.source.json new file mode 100644 index 0000000..4236046 --- /dev/null +++ b/src/toolbox/manifest.source.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://git.add-ideas.de/lotobo/toolbox-sdk/raw/branch/main/schemas/toolbox-app.v1.schema.json", + "schemaVersion": 1, + "id": "de.add-ideas.privacy-tools", + "name": "Privacy Tools", + "version": "0.1.0", + "description": "Inspect and remove shareable-file metadata locally in the browser.", + "entry": "./", + "icon": "./favicon.svg", + "categories": ["privacy", "files", "security"], + "tags": ["metadata", "exif", "privacy", "sanitize", "share"], + "integration": { + "contextVersion": 1, + "launchModes": ["navigate", "new-tab"], + "embedding": "unsupported" + }, + "requirements": { + "secureContext": true, + "workers": true, + "indexedDb": false, + "crossOriginIsolated": false, + "topLevelContext": false + }, + "privacy": { + "processing": "local", + "fileUploads": true, + "telemetry": false, + "label": "Inputs stay in this browser; nothing is uploaded." + }, + "source": { + "repository": "https://git.add-ideas.de/lotobo/privacy-tools", + "license": "GPL-3.0-or-later" + }, + "actions": [ + { + "id": "source", + "label": "Source", + "url": "https://git.add-ideas.de/lotobo/privacy-tools" + } + ] +} diff --git a/src/toolbox/manifest.ts b/src/toolbox/manifest.ts new file mode 100644 index 0000000..5e788f5 --- /dev/null +++ b/src/toolbox/manifest.ts @@ -0,0 +1,4 @@ +import { defineToolboxApp, parseToolboxApp } from "@add-ideas/toolbox-contract"; +import source from "./manifest.source.json"; + +export const manifest = defineToolboxApp(parseToolboxApp(source)); diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 0000000..76162f8 --- /dev/null +++ b/src/version.ts @@ -0,0 +1 @@ +export const APP_VERSION = "0.1.0"; diff --git a/src/vite-env.d.ts b/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/src/worker/protocol.ts b/src/worker/protocol.ts new file mode 100644 index 0000000..4242191 --- /dev/null +++ b/src/worker/protocol.ts @@ -0,0 +1,21 @@ +import type { ImageScanResult, ScanInput } from "../privacy/model"; + +export interface ScanFileRequest { + type: "scan-file"; + requestId: string; + file: ScanInput; +} + +export type ScanWorkerRequest = ScanFileRequest; + +export type ScanWorkerResponse = + | { + type: "scanned"; + requestId: string; + result: ImageScanResult; + } + | { + type: "error"; + requestId: string; + message: string; + }; diff --git a/src/worker/scan.worker.ts b/src/worker/scan.worker.ts new file mode 100644 index 0000000..848bb8f --- /dev/null +++ b/src/worker/scan.worker.ts @@ -0,0 +1,31 @@ +/// + +import { scanImageBytes } from "../privacy/scanner"; +import type { ScanWorkerRequest, ScanWorkerResponse } from "./protocol"; + +const scope = self as DedicatedWorkerGlobalScope; + +scope.addEventListener("message", (event: MessageEvent) => { + if (event.data.type === "scan-file") void scanFile(event.data); +}); + +async function scanFile(request: ScanWorkerRequest): Promise { + try { + post({ + type: "scanned", + requestId: request.requestId, + result: await scanImageBytes(request.file), + }); + } catch (error) { + post({ + type: "error", + requestId: request.requestId, + message: + error instanceof Error ? error.message : "Metadata scanning failed.", + }); + } +} + +function post(message: ScanWorkerResponse): void { + scope.postMessage(message); +} diff --git a/tests/browser/app.spec.ts b/tests/browser/app.spec.ts new file mode 100644 index 0000000..344a14d --- /dev/null +++ b/tests/browser/app.spec.ts @@ -0,0 +1,166 @@ +import { expect, test, type Page } from "@playwright/test"; + +import { pngFixture, tiffFixture } from "../fixtures/images"; + +const ORIGIN = "http://127.0.0.1:4173"; +async function localOnly(page: Page) { + const external: string[] = []; + await page.route("**/*", async (route) => { + const url = new URL(route.request().url()); + if (url.origin !== ORIGIN) { + external.push(url.href); + await route.abort(); + } else await route.continue(); + }); + return external; +} + +test("runs from a nested path without external requests", async ({ page }) => { + const errors: string[] = []; + page.on("pageerror", (error) => errors.push(error.message)); + page.on("console", (message) => { + if (message.type() === "error") errors.push(message.text()); + }); + const external = await localOnly(page); + await page.goto("/deep/nested/privacy/"); + await expect( + page.getByRole("heading", { name: "Privacy Tools" }), + ).toBeVisible(); + expect(external).toEqual([]); + expect(errors).toEqual([]); +}); + +test("serves the release identity and hardened headers", async ({ + request, +}) => { + const index = await request.get("/deep/nested/privacy/"); + expect(index.ok()).toBe(true); + expect(index.headers()["content-security-policy"]).toContain( + "default-src 'self'", + ); + expect(await index.text()).not.toMatch(/\b(?:src|href)=["']\//u); + const manifest = await request.get("/deep/nested/privacy/toolbox-app.json"); + await expect(manifest.json()).resolves.toMatchObject({ + id: "de.add-ideas.privacy-tools", + version: "0.1.0", + entry: "./", + }); +}); + +test("inspects and independently verifies a re-encoded PNG without network access", async ({ + page, +}) => { + const errors: string[] = []; + page.on("pageerror", (error) => errors.push(error.message)); + page.on("console", (message) => { + if (message.type() === "error") errors.push(message.text()); + }); + const external = await localOnly(page); + await page.goto("/deep/nested/privacy/"); + + await page.locator('input[type="file"]').setInputFiles([ + { + name: "metadata-fixture.png", + mimeType: "image/png", + buffer: Buffer.from(pngFixture()), + }, + { + name: "inventory-only.pdf", + mimeType: "application/pdf", + buffer: Buffer.from("%PDF-1.7\n% fixture"), + }, + ]); + await expect( + page.getByRole("heading", { name: "Batch inventory" }), + ).toBeVisible(); + await expect(page.getByText("Alice PNG").first()).toBeVisible(); + await expect(page.getByText("PNG Alice").first()).toBeVisible(); + await expect(page.getByText("inventory-only.pdf").first()).toBeVisible(); + await page.getByRole("button", { name: "Re-encode & verify" }).click(); + await expect(page.getByText("Mandatory output re-scan")).toBeVisible(); + await expect(page.locator(".verification")).not.toHaveClass(/is-failed/u); + await expect( + page.getByRole("button", { name: "Download re-encoded output" }), + ).toBeEnabled(); + + const imageDownload = page.waitForEvent("download"); + await page + .getByRole("button", { name: "Download re-encoded output" }) + .click(); + expect((await imageDownload).suggestedFilename()).toBe( + "metadata-fixture.clean.png", + ); + + const reportDownload = page.waitForEvent("download"); + await page.getByRole("button", { name: "Download JSON report" }).click(); + expect((await reportDownload).suggestedFilename()).toBe( + "privacy-tools-report.json", + ); + const archiveDownload = page.waitForEvent("download"); + await page + .getByRole("button", { name: "Download 1 re-encoded image + report" }) + .click(); + expect((await archiveDownload).suggestedFilename()).toBe( + "privacy-tools-re-encoded-images.zip", + ); + expect(external).toEqual([]); + expect(errors).toEqual([]); +}); + +test("normalizes EXIF orientation while re-encoding JPEG pixels", async ({ + page, +}) => { + const external = await localOnly(page); + await page.goto("/deep/nested/privacy/"); + const encoded = await page.evaluate(async () => { + const canvas = document.createElement("canvas"); + canvas.width = 2; + canvas.height = 1; + const context = canvas.getContext("2d"); + if (!context) throw new Error("Missing test canvas"); + context.fillStyle = "#ff0000"; + context.fillRect(0, 0, 1, 1); + context.fillStyle = "#0000ff"; + context.fillRect(1, 0, 1, 1); + const blob = await new Promise((resolve, reject) => + canvas.toBlob( + (value) => + value ? resolve(value) : reject(new Error("JPEG encode failed")), + "image/jpeg", + 0.95, + ), + ); + return [...new Uint8Array(await blob.arrayBuffer())]; + }); + const jpeg = addExifOrientation(Buffer.from(encoded), 6); + await page.locator('input[type="file"]').setInputFiles({ + name: "oriented.jpg", + mimeType: "image/jpeg", + buffer: jpeg, + }); + await expect(page.getByText("2 × 1 pixels")).toBeVisible(); + await page.getByRole("button", { name: "Re-encode & verify" }).click(); + await expect(page.getByText("Mandatory output re-scan")).toBeVisible(); + await expect(page.locator(".verification")).not.toHaveClass(/is-failed/u); + await expect(page.getByText("Normalized", { exact: true })).toBeVisible(); + expect(external).toEqual([]); +}); + +function addExifOrientation(jpeg: Buffer, orientation: number): Buffer { + const payload = Buffer.concat([ + Buffer.from("Exif\0\0", "binary"), + Buffer.from(tiffFixture({ orientation })), + ]); + const segment = Buffer.from([ + 0xff, + 0xe1, + ((payload.length + 2) >>> 8) & 0xff, + (payload.length + 2) & 0xff, + ]); + return Buffer.concat([ + jpeg.subarray(0, 2), + segment, + payload, + jpeg.subarray(2), + ]); +} diff --git a/tests/components/app.test.tsx b/tests/components/app.test.tsx new file mode 100644 index 0000000..f5b3caf --- /dev/null +++ b/tests/components/app.test.tsx @@ -0,0 +1,18 @@ +import { render, screen } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; +import { App } from "../../src/App"; + +describe("Privacy Tools", () => { + it("renders the local workbench and standard shell", async () => { + vi.stubGlobal( + "fetch", + vi.fn(async () => new Response("Not found", { status: 404 })), + ); + render(); + expect( + await screen.findByRole("heading", { name: "Privacy Tools" }), + ).toBeVisible(); + expect(await screen.findByText("Local & ephemeral")).toBeVisible(); + expect(screen.getAllByText(/No anonymity promise/iu)).not.toHaveLength(0); + }); +}); diff --git a/tests/fixtures/images.ts b/tests/fixtures/images.ts new file mode 100644 index 0000000..6c8aab8 --- /dev/null +++ b/tests/fixtures/images.ts @@ -0,0 +1,253 @@ +import { crc32 } from "@add-ideas/toolbox-helpers"; +import { zlibSync } from "fflate"; + +const encoder = new TextEncoder(); + +export function jpegFixture(options: { trailing?: boolean } = {}): Uint8Array { + const xmp = encoder.encode( + "http://ns.adobe.com/xap/1.0/\0" + + 'Alice Example48.1 NFixture Cameradoc-123', + ); + const jfif = concat( + encoder.encode("JFIF\0"), + bytes(1, 2, 0), + u16be(72), + u16be(72), + bytes(0, 0), + ); + const iptc = concat( + iptcDataset(80, "Alice Reporter"), + iptcDataset(90, "Berlin"), + iptcDataset(120, "Private caption"), + ); + const photoshop = concat( + encoder.encode("Photoshop 3.0\0"), + encoder.encode("8BIM"), + u16be(0x0404), + bytes(0, 0), + u32be(iptc.byteLength), + iptc, + iptc.byteLength % 2 ? bytes(0) : bytes(), + ); + const body = concat( + bytes(0xff, 0xd8), + jpegSegment(0xe0, jfif), + jpegSegment(0xe1, concat(encoder.encode("Exif\0\0"), tiffFixture())), + jpegSegment(0xe1, xmp), + jpegSegment( + 0xe2, + concat( + encoder.encode("ICC_PROFILE\0"), + bytes(1, 1), + encoder.encode("icc"), + ), + ), + jpegSegment(0xeb, encoder.encode("jumb/c2pa test manifest")), + jpegSegment(0xed, photoshop), + jpegSegment(0xfe, encoder.encode("private jpeg comment")), + jpegSegment(0xc0, bytes(8, 0, 2, 0, 3, 1, 1, 0x11, 0)), + bytes(0xff, 0xda, 0xff, 0xd9), + ); + return options.trailing ? concat(body, encoder.encode("hidden")) : body; +} + +export function pngFixture( + options: { + cycleTiff?: boolean; + inflatedCommentBytes?: number; + animated?: boolean; + trailing?: boolean; + } = {}, +): Uint8Array { + const width = 2; + const height = 1; + const ihdr = concat(u32be(width), u32be(height), bytes(8, 6, 0, 0, 0)); + const xmp = encoder.encode( + "XML:com.adobe.xmp\0\0\0\0\0" + + 'PNG AlicePNG Fixture', + ); + const inflated = encoder.encode( + "x".repeat(options.inflatedCommentBytes ?? 32), + ); + const scanline = bytes(0, 255, 0, 0, 255, 0, 0, 255, 255); + const chunks = [ + pngChunk("IHDR", ihdr), + pngChunk("tEXt", encoder.encode("Author\0Alice PNG")), + pngChunk( + "zTXt", + concat(encoder.encode("Comment\0"), bytes(0), zlibSync(inflated)), + ), + pngChunk("iTXt", xmp), + pngChunk("eXIf", tiffFixture({ cycle: options.cycleTiff })), + pngChunk( + "iCCP", + concat( + encoder.encode("fixture profile\0"), + bytes(0), + zlibSync(encoder.encode("ICC profile bytes")), + ), + ), + pngChunk("vpAg", encoder.encode("private ancillary data")), + ...(options.animated ? [pngChunk("acTL", concat(u32be(2), u32be(0)))] : []), + pngChunk("IDAT", zlibSync(scanline)), + pngChunk("IEND", bytes()), + ]; + const image = concat( + bytes(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a), + ...chunks, + ); + return options.trailing + ? concat(image, encoder.encode("trailing secret")) + : image; +} + +export function webpFixture(options: { animated?: boolean } = {}): Uint8Array { + const vp8x = bytes(options.animated ? 0x02 : 0, 0, 0, 0, 3, 0, 0, 2, 0, 0); + const dimensions = 3 | (2 << 14); + const vp8l = concat(bytes(0x2f), u32le(dimensions)); + const xmp = encoder.encode( + 'WebP Alice13.4 E', + ); + const chunks = concat( + riffChunk("VP8X", vp8x), + riffChunk("VP8L", vp8l), + riffChunk("EXIF", concat(encoder.encode("Exif\0\0"), tiffFixture())), + riffChunk("XMP ", xmp), + riffChunk("ICCP", encoder.encode("ICC profile bytes")), + ...(options.animated ? [riffChunk("ANIM", bytes(0, 0, 0, 0, 0, 0))] : []), + ); + return concat( + encoder.encode("RIFF"), + u32le(chunks.byteLength + 4), + encoder.encode("WEBP"), + chunks, + ); +} + +export function tiffFixture( + options: { cycle?: boolean; orientation?: number } = {}, +): Uint8Array { + const make = encoder.encode("CameraCo\0"); + const date = encoder.encode("2026:09:01 12:34:56\0"); + const gpsDate = encoder.encode("2026:09:01\0"); + const mainOffset = 8; + const mainEntries = 4; + const mainEnd = mainOffset + 2 + mainEntries * 12; + const dataStart = mainEnd + 4; + const makeOffset = dataStart; + const dateOffset = makeOffset + make.byteLength; + const gpsOffset = dateOffset + date.byteLength; + const gpsEntries = 2; + const gpsEnd = gpsOffset + 2 + gpsEntries * 12; + const gpsDateOffset = gpsEnd + 4; + const result = new Uint8Array(gpsDateOffset + gpsDate.byteLength); + const view = new DataView(result.buffer); + result.set(bytes(0x49, 0x49), 0); + view.setUint16(2, 42, true); + view.setUint32(4, mainOffset, true); + view.setUint16(mainOffset, mainEntries, true); + writeIfdEntry(view, mainOffset + 2, 0x010f, 2, make.byteLength, makeOffset); + writeIfdEntry(view, mainOffset + 14, 0x0112, 3, 1, options.orientation ?? 1); + writeIfdEntry(view, mainOffset + 26, 0x0132, 2, date.byteLength, dateOffset); + writeIfdEntry(view, mainOffset + 38, 0x8825, 4, 1, gpsOffset); + view.setUint32(mainEnd, options.cycle ? mainOffset : 0, true); + result.set(make, makeOffset); + result.set(date, dateOffset); + view.setUint16(gpsOffset, gpsEntries, true); + writeIfdEntry(view, gpsOffset + 2, 1, 2, 2, 0x4e); + writeIfdEntry(view, gpsOffset + 14, 29, 2, gpsDate.byteLength, gpsDateOffset); + view.setUint32(gpsEnd, 0, true); + result.set(gpsDate, gpsDateOffset); + return result; +} + +export function malformedPngLengthFixture(): Uint8Array { + const image = pngFixture(); + const malformed = image.slice(); + new DataView(malformed.buffer).setUint32(8, 0xfffffff0, false); + return malformed; +} + +export function toArrayBuffer(value: Uint8Array): ArrayBuffer { + return value.slice().buffer as ArrayBuffer; +} + +function jpegSegment(marker: number, payload: Uint8Array): Uint8Array { + return concat(bytes(0xff, marker), u16be(payload.byteLength + 2), payload); +} + +function iptcDataset(dataset: number, value: string): Uint8Array { + const encoded = encoder.encode(value); + return concat(bytes(0x1c, 2, dataset), u16be(encoded.byteLength), encoded); +} + +function pngChunk(type: string, data: Uint8Array): Uint8Array { + const typeBytes = encoder.encode(type); + const checksumInput = concat(typeBytes, data); + return concat( + u32be(data.byteLength), + checksumInput, + u32be(crc32(checksumInput, 16 * 1024 * 1024)), + ); +} + +function riffChunk(type: string, data: Uint8Array): Uint8Array { + return concat( + encoder.encode(type), + u32le(data.byteLength), + data, + data.byteLength % 2 ? bytes(0) : bytes(), + ); +} + +function writeIfdEntry( + view: DataView, + offset: number, + tag: number, + type: number, + count: number, + value: number, +): void { + view.setUint16(offset, tag, true); + view.setUint16(offset + 2, type, true); + view.setUint32(offset + 4, count, true); + if (type === 3 && count === 1) view.setUint16(offset + 8, value, true); + else view.setUint32(offset + 8, value, true); +} + +function concat(...parts: readonly Uint8Array[]): Uint8Array { + const size = parts.reduce((total, part) => total + part.byteLength, 0); + const result = new Uint8Array(size); + let offset = 0; + for (const part of parts) { + result.set(part, offset); + offset += part.byteLength; + } + return result; +} + +function bytes(...values: readonly number[]): Uint8Array { + return Uint8Array.from(values); +} + +function u16be(value: number): Uint8Array { + return bytes((value >>> 8) & 0xff, value & 0xff); +} + +function u32be(value: number): Uint8Array { + return bytes( + (value >>> 24) & 0xff, + (value >>> 16) & 0xff, + (value >>> 8) & 0xff, + value & 0xff, + ); +} + +function u32le(value: number): Uint8Array { + return bytes( + value & 0xff, + (value >>> 8) & 0xff, + (value >>> 16) & 0xff, + (value >>> 24) & 0xff, + ); +} diff --git a/tests/privacy/detect.test.ts b/tests/privacy/detect.test.ts new file mode 100644 index 0000000..49cd04f --- /dev/null +++ b/tests/privacy/detect.test.ts @@ -0,0 +1,48 @@ +import { describe, expect, it } from "vitest"; + +import { + detectKind, + fileExtension, + inventoryIdentity, +} from "../../src/privacy"; +import { jpegFixture, pngFixture, webpFixture } from "../fixtures/images"; + +describe("file identity", () => { + it("detects supported containers from bytes", () => { + expect(detectKind(jpegFixture())).toBe("jpeg"); + expect(detectKind(pngFixture())).toBe("png"); + expect(detectKind(webpFixture())).toBe("webp"); + expect(detectKind(Uint8Array.from([0x25, 0x50, 0x44, 0x46, 0x2d]))).toBe( + "pdf", + ); + }); + + it("normalizes leaf extensions without trusting paths", () => { + expect(fileExtension("folder\\PHOTO.JPEG")).toBe("jpeg"); + expect(fileExtension(".hidden")).toBe(""); + expect(fileExtension("no-extension")).toBe(""); + }); + + it("reports claimed and extension mismatches", () => { + const identity = inventoryIdentity( + "portrait.jpg", + "image/jpeg", + pngFixture(), + ); + expect(identity).toMatchObject({ + detectedKind: "png", + detectedType: "image/png", + typeMatch: "mismatch", + }); + }); + + it("does not infer an unknown payload from its extension", () => { + const identity = inventoryIdentity( + "claim.png", + "image/png", + Uint8Array.from([1, 2, 3]), + ); + expect(identity.detectedKind).toBe("unknown"); + expect(identity.typeMatch).toBe("unknown"); + }); +}); diff --git a/tests/privacy/limits.test.ts b/tests/privacy/limits.test.ts new file mode 100644 index 0000000..460794b --- /dev/null +++ b/tests/privacy/limits.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, it } from "vitest"; + +import { + assertBatchFiles, + PrivacyLimitError, + resolveLimits, +} from "../../src/privacy"; + +describe("privacy resource limits", () => { + it("rejects too many, oversized and collectively oversized files", () => { + expect(() => + assertBatchFiles([{ size: 1 }, { size: 1 }], { + ...resolveLimits(), + maxFiles: 1, + }), + ).toThrow(PrivacyLimitError); + expect(() => + assertBatchFiles([{ size: 11 }], { + ...resolveLimits(), + maxFileBytes: 10, + }), + ).toThrow(PrivacyLimitError); + expect(() => + assertBatchFiles([{ size: 6 }, { size: 6 }], { + ...resolveLimits(), + maxFileBytes: 10, + maxBatchBytes: 10, + }), + ).toThrow(PrivacyLimitError); + }); + + it("rejects invalid limit overrides", () => { + expect(() => resolveLimits({ maxFiles: 0 })).toThrow( + /positive safe integer/iu, + ); + expect(() => resolveLimits({ maxFileBytes: Number.NaN })).toThrow( + /positive safe integer/iu, + ); + }); +}); diff --git a/tests/privacy/report.test.ts b/tests/privacy/report.test.ts new file mode 100644 index 0000000..2afb959 --- /dev/null +++ b/tests/privacy/report.test.ts @@ -0,0 +1,207 @@ +// @vitest-environment node + +import { unzipSync } from "fflate"; +import { describe, expect, it } from "vitest"; + +import { + buildSanitizationReport, + createBatchArchive, + createBatchReport, + serializeReport, + type ImageScanResult, + type MetadataFinding, +} from "../../src/privacy"; + +const sensitive: MetadataFinding = { + id: "gps-1", + category: "location", + risk: "sensitive", + source: "EXIF", + label: "GPS Latitude", + value: "48.1 N", +}; + +describe("sanitization and batch reports", () => { + it("marks a complete sensitive-free output verified and records removals", () => { + const source = result({ findings: [sensitive] }); + const output = result({ id: "clean", name: "clean.png", findings: [] }); + const report = buildSanitizationReport( + source, + output, + "clean.png", + "image/png", + 20, + comparison(true), + ); + expect(report.status).toBe("verified"); + expect(report.removed).toEqual([sensitive]); + expect(report.preserved).toEqual([]); + expect(report.orientationNormalized).toBe(true); + expect(report.disclaimer).toMatch(/not an anonymity guarantee/iu); + }); + + it("fails a partial or sensitive output re-scan", () => { + const source = result({ findings: [sensitive] }); + const output = result({ + id: "clean", + findings: [sensitive], + coverage: { + projectScanner: "partial", + secondaryScanner: "complete", + notes: [], + }, + }); + const report = buildSanitizationReport( + source, + output, + "clean.png", + "image/png", + 20, + comparison(false), + ); + expect(report.status).toBe("failed"); + expect(report.preserved).toEqual([sensitive]); + expect(report.incomplete).not.toEqual([]); + }); + + it("reports an unknown browser-generated output chunk as a warning", () => { + const source = result(); + const output = result({ + id: "clean", + findings: [ + { + id: "private-1", + category: "unknown", + risk: "context", + source: "PNG", + label: "Private chunk deBG", + value: "16 bytes", + }, + ], + blocks: [{ kind: "deBG", offset: 40, length: 16 }], + }); + const report = buildSanitizationReport( + source, + output, + "clean.png", + "image/png", + 20, + comparison(true), + ); + expect(report.status).toBe("warning"); + expect(report.generated).toHaveLength(1); + expect(report.incomplete.join(" ")).toContain("deBG"); + }); + + it("fails a changed decoded sample for lossless PNG", () => { + const report = buildSanitizationReport( + result(), + result({ id: "clean" }), + "clean.png", + "image/png", + 20, + comparison(false), + ); + expect(report.status).toBe("failed"); + expect(report.incomplete.join(" ")).toMatch(/pixel sample/iu); + }); + + it("produces deterministic, safe JSON and a stored batch ZIP", async () => { + const source = result({ name: "../private.png", findings: [sensitive] }); + const output = result({ id: "clean", name: "private.clean.png" }); + const report = buildSanitizationReport( + source, + output, + "../same.png", + "image/png", + 3, + comparison(true), + ); + const assets = [ + { blob: new Blob([Uint8Array.of(1, 2, 3)]), report }, + { blob: new Blob([Uint8Array.of(4, 5, 6)]), report }, + ]; + const generatedAt = "2026-09-01T00:00:00.000Z"; + const batch = createBatchReport([source], assets, generatedAt); + const json = serializeReport(batch); + expect(JSON.parse(json)).toMatchObject({ schemaVersion: 1, generatedAt }); + expect(json).toContain("report may itself contain sensitive"); + + const archive = await createBatchArchive([source], assets, generatedAt); + const entries = unzipSync(new Uint8Array(await archive.arrayBuffer())); + expect(Object.keys(entries).sort()).toEqual([ + "images/_same-2.png", + "images/_same.png", + "privacy-tools-report.json", + ]); + expect( + JSON.parse( + new TextDecoder().decode(entries["privacy-tools-report.json"]), + ), + ).toMatchObject({ schemaVersion: 1, generatedAt }); + }); + + it("bounds archive entry count before reading output blobs", async () => { + const source = result(); + const output = result({ id: "clean" }); + const report = buildSanitizationReport( + source, + output, + "clean.png", + "image/png", + 1, + comparison(true), + ); + const asset = { blob: new Blob([Uint8Array.of(0)]), report }; + await expect( + createBatchArchive( + [source], + Array.from({ length: 101 }, () => asset), + ), + ).rejects.toThrow(/Archive image count/iu); + }); +}); + +function comparison(identical: boolean) { + return { + method: "oriented-256px-sample" as const, + sourceDigest: "source-sample", + outputDigest: identical ? "source-sample" : "output-sample", + identical, + note: "test comparison", + }; +} + +function result(overrides: Partial = {}): ImageScanResult { + return { + id: "source", + name: "source.png", + safeName: "source.png", + size: 100, + lastModified: 0, + sha256: "a".repeat(64), + identity: { + claimedType: "image/png", + extension: "png", + detectedKind: "png", + detectedType: "image/png", + typeMatch: "match", + }, + width: 2, + height: 1, + orientation: 1, + animated: false, + multiImage: false, + deepSupported: true, + cleanable: true, + findings: [], + blocks: [], + warnings: [], + coverage: { + projectScanner: "complete", + secondaryScanner: "complete", + notes: [], + }, + ...overrides, + }; +} diff --git a/tests/privacy/scanner.test.ts b/tests/privacy/scanner.test.ts new file mode 100644 index 0000000..ae5d86a --- /dev/null +++ b/tests/privacy/scanner.test.ts @@ -0,0 +1,236 @@ +import { describe, expect, it } from "vitest"; + +import { PrivacyLimitError, scanImageBytes } from "../../src/privacy"; +import { + jpegFixture, + malformedPngLengthFixture, + pngFixture, + toArrayBuffer, + webpFixture, +} from "../fixtures/images"; + +describe("bounded image metadata scanner", () => { + it("extracts JPEG EXIF, IPTC, XMP, JFIF, ICC and provenance", async () => { + const result = await scan("camera.jpg", "image/jpeg", jpegFixture()); + + expect(result).toMatchObject({ + width: 3, + height: 2, + orientation: 1, + animated: false, + multiImage: false, + deepSupported: true, + cleanable: true, + }); + expect(result.coverage.projectScanner).toBe("complete"); + expect(result.findings).toEqual( + expect.arrayContaining([ + expect.objectContaining({ category: "location" }), + expect.objectContaining({ category: "identity" }), + expect.objectContaining({ category: "timestamp" }), + expect.objectContaining({ category: "device" }), + expect.objectContaining({ category: "colour-profile" }), + expect.objectContaining({ category: "provenance" }), + ]), + ); + expect(result.blocks.map((block) => block.kind)).toEqual( + expect.arrayContaining(["APP0", "APP1", "APP2", "APP11", "APP13", "COM"]), + ); + }); + + it("extracts PNG text, compressed text, EXIF, XMP, ICC and private chunks", async () => { + const result = await scan("fixture.png", "image/png", pngFixture()); + + expect(result).toMatchObject({ + width: 2, + height: 1, + orientation: 1, + cleanable: true, + }); + expect(result.coverage.projectScanner).toBe("complete"); + expect( + result.findings.some((finding) => finding.value.includes("Alice PNG")), + ).toBe(true); + expect( + result.findings.some((finding) => finding.value.includes("PNG Alice")), + ).toBe(true); + expect(result.blocks.map((block) => block.kind)).toEqual( + expect.arrayContaining(["tEXt", "zTXt", "iTXt", "eXIf", "iCCP", "vpAg"]), + ); + }); + + it("extracts WebP EXIF, XMP, ICC and extended dimensions", async () => { + const result = await scan("fixture.webp", "image/webp", webpFixture()); + + expect(result).toMatchObject({ + width: 4, + height: 3, + orientation: 1, + animated: false, + cleanable: true, + }); + expect(result.coverage.projectScanner).toBe("complete"); + expect(result.findings).toEqual( + expect.arrayContaining([ + expect.objectContaining({ category: "location" }), + expect.objectContaining({ category: "identity" }), + expect.objectContaining({ category: "colour-profile" }), + ]), + ); + }); + + it("makes animated images inspect-only", async () => { + const png = await scan( + "animated.png", + "image/png", + pngFixture({ animated: true }), + ); + const webp = await scan( + "animated.webp", + "image/webp", + webpFixture({ animated: true }), + ); + expect(png.animated).toBe(true); + expect(webp.animated).toBe(true); + expect(png.cleanable).toBe(false); + expect(webp.cleanable).toBe(false); + }); + + it("reports trailing data rather than hiding it", async () => { + const jpeg = await scan( + "tail.jpg", + "image/jpeg", + jpegFixture({ trailing: true }), + ); + const png = await scan( + "tail.png", + "image/png", + pngFixture({ trailing: true }), + ); + expect( + jpeg.findings.some((finding) => finding.label === "Trailing data"), + ).toBe(true); + expect( + png.findings.some((finding) => finding.label === "Trailing data"), + ).toBe(true); + }); + + it("stops malformed chunks and TIFF cycles and refuses clean-copy eligibility", async () => { + const malformed = await scan( + "malformed.png", + "image/png", + malformedPngLengthFixture(), + ); + const cyclic = await scan( + "cycle.png", + "image/png", + pngFixture({ cycleTiff: true }), + ); + expect(malformed.coverage.projectScanner).toBe("partial"); + expect(malformed.cleanable).toBe(false); + expect(cyclic.coverage.projectScanner).toBe("partial"); + expect(cyclic.warnings.join(" ")).toMatch(/cycle/iu); + expect(cyclic.cleanable).toBe(false); + }); + + it("bounds compressed metadata and finding values", async () => { + const image = pngFixture({ inflatedCommentBytes: 1024 }); + const result = await scanImageBytes(input("bomb.png", "image/png", image), { + maxInflatedMetadataBytes: 32, + maxFindingValueChars: 24, + }); + expect(result.coverage.projectScanner).toBe("partial"); + expect(result.warnings.join(" ")).toMatch(/limit|fully read/iu); + expect(result.findings.every((finding) => finding.value.length <= 25)).toBe( + true, + ); + }); + + it("bounds chunk counts and decoded dimensions", async () => { + const image = pngFixture(); + const tooManyChunks = await scanImageBytes( + input("chunks.png", "image/png", image), + { maxMetadataBlocks: 3 }, + ); + const tooManyPixels = await scanImageBytes( + input("pixels.png", "image/png", image), + { maxPixels: 1 }, + ); + expect(tooManyChunks.coverage.projectScanner).toBe("partial"); + expect(tooManyChunks.cleanable).toBe(false); + expect(tooManyPixels.cleanable).toBe(false); + expect(tooManyPixels.warnings.join(" ")).toMatch(/processing limit/iu); + }); + + it("bounds aggregate normalized finding text", async () => { + const image = pngFixture(); + const result = await scanImageBytes(input("text.png", "image/png", image), { + maxFindingTextChars: 100, + }); + expect(result.coverage.projectScanner).toBe("partial"); + expect(result.coverage.notes.join(" ")).toMatch(/text limit/iu); + expect(result.cleanable).toBe(false); + }); + + it("treats invalid PNG CRCs as partial coverage", async () => { + const image = pngFixture().slice(); + image[image.length - 1] = (image[image.length - 1] ?? 0) ^ 0xff; + const result = await scan("crc.png", "image/png", image); + expect(result.coverage.projectScanner).toBe("partial"); + expect(result.warnings.join(" ")).toMatch(/invalid CRC/iu); + expect(result.cleanable).toBe(false); + }); + + it("contains malformed HEIF-family input in the secondary adapter", async () => { + const malformedHeic = Uint8Array.from([ + 0, 0, 0, 16, 0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63, 0, 0, 0, 0, + ]); + const result = await scan("broken.heic", "image/heic", malformedHeic); + expect(result.identity.detectedKind).toBe("heic"); + expect(["failed", "unsupported", "partial"]).toContain( + result.coverage.secondaryScanner, + ); + expect(result.cleanable).toBe(false); + }); + + it("rejects dishonest declared sizes and file limits before parsing", async () => { + const image = pngFixture(); + await expect( + scanImageBytes({ + ...input("wrong.png", "image/png", image), + size: image.length + 1, + }), + ).rejects.toThrow(/does not match/iu); + await expect( + scanImageBytes(input("large.png", "image/png", image), { + maxFileBytes: image.length - 1, + }), + ).rejects.toBeInstanceOf(PrivacyLimitError); + }); + + it("keeps non-image formats at inventory-only coverage", async () => { + const pdf = Uint8Array.from([ + 0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x37, + ]); + const result = await scan("document.pdf", "application/pdf", pdf); + expect(result.identity.detectedKind).toBe("pdf"); + expect(result.deepSupported).toBe(false); + expect(result.cleanable).toBe(false); + expect(result.coverage.projectScanner).toBe("unsupported"); + }); +}); + +async function scan(name: string, type: string, bytes: Uint8Array) { + return scanImageBytes(input(name, type, bytes)); +} + +function input(name: string, type: string, bytes: Uint8Array) { + return { + id: `fixture-${name}`, + name, + claimedType: type, + size: bytes.byteLength, + lastModified: 0, + bytes: toArrayBuffer(bytes), + }; +} diff --git a/tsconfig.app.json b/tsconfig.app.json new file mode 100644 index 0000000..0a14c25 --- /dev/null +++ b/tsconfig.app.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2023", + "lib": ["ES2023", "DOM", "DOM.Iterable"], + "module": "ESNext", + "types": ["vite/client"], + "allowArbitraryExtensions": true, + "skipLibCheck": true, + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "useDefineForClassFields": true, + "resolveJsonModule": true, + "isolatedModules": true + }, + "include": ["src", "tests"] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ea9d0cd --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.node.json" + } + ] +} diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 0000000..df3e8ce --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2023", + "lib": ["ES2023"], + "module": "ESNext", + "types": ["node"], + "skipLibCheck": true, + "moduleResolution": "Bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true + }, + "include": [ + "vite.config.ts", + "playwright.config.ts", + "eslint.config.mjs", + "scripts/**/*.mjs" + ] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..af3c56b --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,16 @@ +/// +import { defineConfig } from "vite"; +import react from "@vitejs/plugin-react"; + +export default defineConfig({ + base: "./", + plugins: [react()], + test: { + environment: "jsdom", + setupFiles: "./src/test/setup.ts", + css: true, + maxWorkers: 2, + restoreMocks: true, + exclude: ["tests/browser/**", "node_modules/**", "dist/**"], + }, +});