diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 5abfbb4..8039a04 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -36,7 +36,7 @@ If applicable, add screenshots to help explain your problem. **Bug occurs on official PairDrop instance https://pairdrop.net/** No | Yes -Version: v1.11.2 +Version: v1.10.10 **Bug occurs on self-hosted PairDrop instance** No | Yes @@ -44,7 +44,7 @@ No | Yes **Self-Hosted Setup** Proxy: Nginx | Apache2 Deployment: docker run | docker compose | npm run start:prod -Version: v1.11.2 +Version: v1.10.10 **Additional context** Add any other context about the problem here. diff --git a/README.md b/README.md index 3400704..d34786d 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,13 @@

Local file sharing in your web browser. -
- Inspired by Apple's AirDrop. -
- Fork of Snapdrop. -
-
+
+
Report a bug
Request feature

-
## Features File sharing on your local network that works on all platforms. @@ -110,7 +105,6 @@ Connect to others in complex network situations, or over the Internet. * [NoSleep](https://github.com/richtr/NoSleep.js) display sleep, add wake lock ([MIT](licenses/MIT-NoSleep)) * [heic2any](https://github.com/alexcorvi/heic2any) HEIC/HEIF to PNG/GIF/JPEG ([MIT](licenses/MIT-heic2any)) * [Weblate](https://weblate.org/) web-based localization tool -* [BrowserStack](https://www.browserstack.com/) This project is tested with BrowserStack [FAQ](docs/faq.md) diff --git a/docs/faq.md b/docs/faq.md index c685658..90eed40 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -188,7 +188,7 @@ to learn more about STUN, TURN and WebRTC.
Yes. Your files are sent using WebRTC, encrypting them in transit. -Still you have to trust the PairDrop server. To ensure the connection is secure and there is no [MITM](https://en.m.wikipedia.org/wiki/Man-in-the-middle_attack) there is a plan to make PairDrop +Still you have to trust the PairDrop server. To ensure the connection is secure and there is no [MITM](https://wikiless.org/wiki/Man-in-the-middle_attack) there is a plan to make PairDrop zero trust by encrypting the signaling and implementing a verification process. See [issue #180](https://github.com/schlagmichdoch/PairDrop/issues/180) to keep updated.
diff --git a/docs/host-your-own.md b/docs/host-your-own.md index f846db7..2c22a3d 100644 --- a/docs/host-your-own.md +++ b/docs/host-your-own.md @@ -556,6 +556,10 @@ a2enmod proxy a2enmod proxy_http ``` +```bash +a2enmod proxy_wstunnel +``` +
Create a new configuration file under `/etc/apache2/sites-available` (on Debian) @@ -566,10 +570,18 @@ Create a new configuration file under `/etc/apache2/sites-available` (on Debian) ```apacheconf - ProxyPass / http://127.0.0.1:3000/ upgrade=websocket + ProxyPass / http://127.0.0.1:3000/ + RewriteEngine on + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteRule ^/?(.*) "ws://127.0.0.1:3000/$1" [P,L] - ProxyPass / https://127.0.0.1:3000/ upgrade=websocket + ProxyPass / https://127.0.0.1:3000/ + RewriteEngine on + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteRule ^/?(.*) "wws://127.0.0.1:3000/$1" [P,L] ``` @@ -577,10 +589,14 @@ Create a new configuration file under `/etc/apache2/sites-available` (on Debian) ```apacheconf - Redirect permanent / https://127.0.0.1:3000/ + Redirect permanent / https://127.0.0.1:3000/ - ProxyPass / http://127.0.0.1:3000/ upgrade=websocket + ProxyPass / https://127.0.0.1:3000/ + RewriteEngine on + RewriteCond %{HTTP:Upgrade} websocket [NC] + RewriteCond %{HTTP:Connection} upgrade [NC] + RewriteRule ^/?(.*) "wws://127.0.0.1:3000/$1" [P,L] ``` diff --git a/docs/how-to.md b/docs/how-to.md index df6d3a1..6513b13 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -45,11 +45,11 @@ This pairdrop-cli version was released alongside v1.10.4 #### Linux / Mac 1. Download the latest _pairdrop-cli.zip_ from the [releases page](https://github.com/schlagmichdoch/PairDrop/releases) ```shell - wget "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.11.2/pairdrop-cli.zip" + wget "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.10.10/pairdrop-cli.zip" ``` or ```shell - curl -LO "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.11.2/pairdrop-cli.zip" + curl -LO "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.10.10/pairdrop-cli.zip" ``` 2. Unzip the archive to a folder of your choice e.g. `/usr/share/pairdrop-cli/` ```shell diff --git a/package-lock.json b/package-lock.json index be60a08..42a0b80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pairdrop", - "version": "1.11.2", + "version": "1.10.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pairdrop", - "version": "1.11.2", + "version": "1.10.10", "license": "ISC", "dependencies": { "express": "^4.18.2", @@ -37,9 +37,9 @@ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, "node_modules/body-parser": { - "version": "1.20.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", - "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", + "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.5", @@ -49,7 +49,7 @@ "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.13.0", + "qs": "6.11.0", "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" @@ -67,25 +67,16 @@ "node": ">= 0.8" } }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dependencies": { + "es-define-property": "^1.0.0", "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz", - "integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "get-intrinsic": "^1.2.6" + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" }, "engines": { "node": ">= 0.4" @@ -114,9 +105,9 @@ } }, "node_modules/cookie": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", - "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } @@ -134,6 +125,22 @@ "ms": "2.0.0" } }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -151,36 +158,26 @@ "npm": "1.2.8000 || >= 1.4.16" } }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/ee-first": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", "engines": { "node": ">= 0.8" } }, "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, "engines": { "node": ">= 0.4" } @@ -193,17 +190,6 @@ "node": ">= 0.4" } }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -218,36 +204,36 @@ } }, "node_modules/express": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", - "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.3", + "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.7.1", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~2.0.0", + "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.3.1", + "finalhandler": "1.2.0", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.3", + "merge-descriptors": "1.0.1", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.12", + "path-to-regexp": "0.1.7", "proxy-addr": "~2.0.7", - "qs": "6.13.0", + "qs": "6.11.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.19.0", - "serve-static": "1.16.2", + "send": "0.18.0", + "serve-static": "1.15.0", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -256,16 +242,12 @@ }, "engines": { "node": ">= 0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" } }, "node_modules/express-rate-limit": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.0.tgz", - "integrity": "sha512-eB5zbQh5h+VenMPM3fh+nw1YExi5nMr6HUCR62ELSP11huvxm/Uir1H1QEyTkk5QX6A58pX6NmaTMceKZ0Eodg==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.3.1.tgz", + "integrity": "sha512-BbaryvkY4wEgDqLgD18/NSy2lDO2jTuT9Y8c1Mpx0X63Yz0sYd5zN6KPe7UvpuSVvV33T6RaE1o1IVZQjHMYgw==", "engines": { "node": ">= 16" }, @@ -273,16 +255,16 @@ "url": "https://github.com/sponsors/express-rate-limit" }, "peerDependencies": { - "express": "^4.11 || 5 || ^5.0.0-beta.1" + "express": "4 || 5 || ^5.0.0-beta.1" } }, "node_modules/finalhandler": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", - "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", "dependencies": { "debug": "2.6.9", - "encodeurl": "~2.0.0", + "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -318,20 +300,15 @@ } }, "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" }, "engines": { "node": ">= 0.4" @@ -340,22 +317,32 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-proto": { + "node_modules/gopd": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" + "get-intrinsic": "^1.1.3" }, - "engines": { - "node": ">= 0.4" + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", "engines": { "node": ">= 0.4" }, @@ -364,9 +351,9 @@ } }, "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", "engines": { "node": ">= 0.4" }, @@ -424,14 +411,6 @@ "node": ">= 0.10" } }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "engines": { - "node": ">= 0.4" - } - }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -441,12 +420,9 @@ } }, "node_modules/merge-descriptors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", - "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" }, "node_modules/methods": { "version": "1.1.2", @@ -500,9 +476,9 @@ } }, "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", + "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", "engines": { "node": ">= 0.4" }, @@ -530,9 +506,9 @@ } }, "node_modules/path-to-regexp": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", - "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==" + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, "node_modules/proxy-addr": { "version": "2.0.7", @@ -547,11 +523,11 @@ } }, "node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "version": "6.11.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", + "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", "dependencies": { - "side-channel": "^1.0.6" + "side-channel": "^1.0.4" }, "engines": { "node": ">=0.6" @@ -607,9 +583,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/send": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", - "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", "dependencies": { "debug": "2.6.9", "depd": "2.0.0", @@ -629,98 +605,55 @@ "node": ">= 0.8.0" } }, - "node_modules/send/node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, "node_modules/serve-static": { - "version": "1.16.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", - "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", "dependencies": { - "encodeurl": "~2.0.0", + "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.19.0" + "send": "0.18.0" }, "engines": { "node": ">= 0.8.0" } }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dependencies": { + "call-bind": "^1.0.7", "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", - "side-channel-map": "^1.0.1", - "side-channel-weakmap": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", - "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-weakmap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", - "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3", - "side-channel-map": "^1.0.1" + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" }, "engines": { "node": ">= 0.4" @@ -758,9 +691,9 @@ } }, "node_modules/ua-parser-js": { - "version": "1.0.40", - "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.40.tgz", - "integrity": "sha512-z6PJ8Lml+v3ichVojCiB8toQJBuwR42ySM4ezjXIqXK3M0HczmKQ3LF4rhU55PfD99KEEXQG6yb7iOMyvYuHew==", + "version": "1.0.38", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.38.tgz", + "integrity": "sha512-Aq5ppTOfvrCMgAPneW1HfWj66Xi7XL+/mIy996R1/CLS/rcyJQm6QZdsKrUeivDFQ+Oc9Wyuwor8Ze8peEoUoQ==", "funding": [ { "type": "opencollective", @@ -775,9 +708,6 @@ "url": "https://github.com/sponsors/faisalman" } ], - "bin": { - "ua-parser-js": "script/cli.js" - }, "engines": { "node": "*" } @@ -815,9 +745,9 @@ } }, "node_modules/ws": { - "version": "8.18.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz", - "integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index e4032f6..5ed2324 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pairdrop", - "version": "1.11.2", + "version": "1.10.10", "type": "module", "description": "", "main": "server/index.js", diff --git a/public/index.html b/public/index.html index 70eda5b..a2c4584 100644 --- a/public/index.html +++ b/public/index.html @@ -10,7 +10,6 @@ - @@ -189,173 +188,128 @@ - - - - - - - - - -
@@ -417,12 +371,12 @@

-
-
+
+

-

+

@@ -668,7 +622,7 @@

PairDrop

-
v1.11.2
+
v1.10.10
@@ -682,9 +636,9 @@ - + - + ${url}`; + return `${whitespaceOrSpecial}${linkNodePlaceholder}`; + } // link is not valid -> do not replace return match; - } - - // link is valid -> replace with link node placeholder - // find linkNodePlaceholder that is not yet present in text node - m++; - while (occP.includes(`${p}${m}`)) { - m++; - } - let linkNodePlaceholder = `${p}${m}`; - - // add linkNodePlaceholder to text node and save a reference to linkNodes object - linkNodes[linkNodePlaceholder] = `${url}`; - return `${whitespace}${linkNodePlaceholder}`; - } - - text = text.replace(rgxUrlAll, replaceMatchWithPlaceholder); - $textShadow.innerText = text.replace(rgxMailAll, replaceMatchWithPlaceholder); + }); this.$text.innerHTML = $textShadow.innerHTML.replace(pRgx, @@ -2404,7 +2380,7 @@ class Base64Dialog extends Dialog { class AboutUI { constructor() { this.$donationBtn = $('donation-btn'); - this.$twitterBtn = $('x-twitter-btn'); + this.$twitterBtn = $('twitter-btn'); this.$mastodonBtn = $('mastodon-btn'); this.$blueskyBtn = $('bluesky-btn'); this.$customBtn = $('custom-btn'); diff --git a/public/scripts/util.js b/public/scripts/util.js index 24e2626..fc418ff 100644 --- a/public/scripts/util.js +++ b/public/scripts/util.js @@ -392,25 +392,24 @@ const mime = (() => { "vob": "video/x-ms-vob", "wmv": "video/x-ms-wmv", "avi": "video/x-msvideo", - "*": "video/x-sgi-movie", - "kdbx": "application/x-keepass2" + "*": "video/x-sgi-movie" } return { - guessMimeByFilename(filename) { + async guessMimeByFilename(filename) { const split = filename.split('.'); if (split.length === 1) { // Filename does not include suffix - return false; + return ""; } const suffix = split[split.length - 1].toLowerCase(); - return suffixToMimeMap[suffix]; + return suffixToMimeMap[suffix] || ""; }, - addMissingMimeTypesToFiles(files) { + async addMissingMimeTypesToFiles(files) { // if filetype is empty guess via suffix otherwise leave unchanged for (let i = 0; i < files.length; i++) { if (!files[i].type) { - files[i] = new File([files[i]], files[i].name, {type: mime.guessMimeByFilename(files[i].name) || "application/octet-stream"}); + files[i] = new File([files[i]], files[i].name, {type: await mime.guessMimeByFilename(files[i].name) || ""}); } } return files; @@ -478,16 +477,13 @@ function getThumbnailAsDataUrl(file, width = undefined, height = undefined, qual return new Promise(async (resolve, reject) => { try { if (file.type === "image/heif" || file.type === "image/heic") { - // hotfix: Converting heic images taken on iOS 18 crashes page. Waiting for PR #350 - reject(new Error(`Hotfix: Converting of HEIC/HEIF images currently disabled.`)); - return; - // // browsers can't show heic files --> convert to jpeg before creating thumbnail - // let blob = await fileToBlob(file); - // file = await heic2any({ - // blob, - // toType: "image/jpeg", - // quality: quality - // }); + // browsers can't show heic files --> convert to jpeg before creating thumbnail + let blob = await fileToBlob(file); + file = await heic2any({ + blob, + toType: "image/jpeg", + quality: quality + }); } let imageUrl = URL.createObjectURL(file); @@ -591,7 +587,7 @@ async function decodeBase64Text(base64) { function isUrlValid(url) { try { - new URL(url); + let urlObj = new URL(url); return true; } catch (e) { diff --git a/public/scripts/worker/canvas-worker.js b/public/scripts/worker/canvas-worker.js deleted file mode 100644 index ff2650f..0000000 --- a/public/scripts/worker/canvas-worker.js +++ /dev/null @@ -1,141 +0,0 @@ -self.onmessage = (e) => { - switch (e.data.type) { - case "createCanvas": createCanvas(e.data); - break; - case "initCanvas": initCanvas(e.data.footerOffsetHeight, e.data.clientWidth, e.data.clientHeight); - break; - case "startAnimation": startAnimation(); - break; - case "onShareModeChange": onShareModeChange(e.data.active); - break; - case "switchAnimation": switchAnimation(e.data.animate); - break; - } -}; - -let baseColorNormal; -let baseColorShareMode; -let baseOpacityNormal; -let baseOpacityShareMode; -let speed; -let fps; - -let c; -let cCtx; - -let x0, y0, w, h, dw, offset; - -let startTime; -let animate = true; -let currentFrame = 0; -let lastFrame; -let baseColor; -let baseOpacity; - -function createCanvas(data) { - baseColorNormal = data.baseColorNormal; - baseColorShareMode = data.baseColorShareMode; - baseOpacityNormal = data.baseOpacityNormal; - baseOpacityShareMode = data.baseOpacityShareMode; - speed = data.speed; - fps = data.fps; - - c = data.canvas; - cCtx = c.getContext("2d"); - - lastFrame = fps / speed - 1; - baseColor = baseColorNormal; - baseOpacity = baseOpacityNormal; -} - -function initCanvas(footerOffsetHeight, clientWidth, clientHeight) { - let oldW = w; - let oldH = h; - let oldOffset = offset; - w = clientWidth; - h = clientHeight; - offset = footerOffsetHeight - 28; - - if (oldW === w && oldH === h && oldOffset === offset) return; // nothing has changed - - c.width = w; - c.height = h; - x0 = w / 2; - y0 = h - offset; - dw = Math.round(Math.min(Math.max(0.6 * w, h)) / 10); - - drawFrame(currentFrame); -} - -function startAnimation() { - startTime = Date.now(); - animateBg(); -} - -function switchAnimation(state) { - if (!animate && state) { - // animation starts again. Set startTime to specific value to prevent frame jump - startTime = Date.now() - 1000 * currentFrame / fps; - } - animate = state; - requestAnimationFrame(animateBg); -} - -function onShareModeChange(active) { - baseColor = active ? baseColorShareMode : baseColorNormal; - baseOpacity = active ? baseOpacityShareMode : baseOpacityNormal; - drawFrame(currentFrame); -} - -function drawCircle(ctx, radius) { - ctx.lineWidth = 2; - - let opacity = Math.max(0, baseOpacity * (1 - 1.2 * radius / Math.max(w, h))); - if (radius > dw * 7) { - opacity *= (8 * dw - radius) / dw - } - - if (ctx.setStrokeColor) { - // older blink/webkit based browsers do not understand opacity in strokeStyle. Use deprecated setStrokeColor instead - // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/strokeStyle#webkitblink-specific_note - ctx.setStrokeColor("grey", opacity); - } - else { - ctx.strokeStyle = `rgb(${baseColor} / ${opacity})`; - } - ctx.beginPath(); - ctx.arc(x0, y0, radius, 0, 2 * Math.PI); - ctx.stroke(); -} - -function drawCircles(ctx, frame) { - ctx.clearRect(0, 0, w, h); - for (let i = 7; i >= 0; i--) { - drawCircle(ctx, dw * i + speed * dw * frame / fps + 33); - } -} - -function drawFrame(frame) { - cCtx.clearRect(0, 0, w, h); - drawCircles(cCtx, frame); -} - -function animateBg() { - let now = Date.now(); - - if (!animate && currentFrame === lastFrame) { - // Animation stopped and cycle finished -> stop drawing frames - return; - } - - let timeSinceLastFullCycle = (now - startTime) % (1000 / speed); - let nextFrame = Math.trunc(fps * timeSinceLastFullCycle / 1000); - - // Only draw frame if it differs from current frame - if (nextFrame !== currentFrame) { - drawFrame(nextFrame); - currentFrame = nextFrame; - } - - requestAnimationFrame(animateBg); -} \ No newline at end of file diff --git a/public/scripts/libs/zip.min.js b/public/scripts/zip.min.js similarity index 100% rename from public/scripts/libs/zip.min.js rename to public/scripts/zip.min.js diff --git a/public/service-worker.js b/public/service-worker.js index e1f4f45..c247828 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,24 +1,22 @@ -const cacheVersion = 'v1.11.2'; +const cacheVersion = 'v1.10.10'; const cacheTitle = `pairdrop-cache-${cacheVersion}`; +const forceFetch = false; // FOR DEVELOPMENT: Set to true to always update assets instead of using cached versions const relativePathsToCache = [ './', 'index.html', 'manifest.json', 'styles/styles-main.css', 'styles/styles-deferred.css', - 'scripts/browser-tabs-connector.js', 'scripts/localization.js', 'scripts/main.js', 'scripts/network.js', + 'scripts/no-sleep.min.js', 'scripts/persistent-storage.js', + 'scripts/qr-code.min.js', 'scripts/ui.js', 'scripts/ui-main.js', 'scripts/util.js', - 'scripts/worker/canvas-worker.js', - 'scripts/libs/heic2any.min.js', - 'scripts/libs/no-sleep.min.js', - 'scripts/libs/qr-code.min.js', - 'scripts/libs/zip.min.js', + 'scripts/zip.min.js', 'sounds/blop.mp3', 'sounds/blop.ogg', 'images/favicon-96x96.png', @@ -28,19 +26,14 @@ const relativePathsToCache = [ 'images/android-chrome-512x512.png', 'images/android-chrome-512x512-maskable.png', 'images/apple-touch-icon.png', - 'fonts/OpenSans/static/OpenSans-Medium.ttf', 'lang/ar.json', 'lang/be.json', - 'lang/bg.json', 'lang/ca.json', 'lang/cs.json', 'lang/da.json', 'lang/de.json', 'lang/en.json', 'lang/es.json', - 'lang/et.json', - 'lang/eu.json', - 'lang/fa.json', 'lang/fr.json', 'lang/he.json', 'lang/hu.json', @@ -48,20 +41,15 @@ const relativePathsToCache = [ 'lang/it.json', 'lang/ja.json', 'lang/kn.json', - 'lang/ko.json', 'lang/nb.json', 'lang/nl.json', - 'lang/nn.json', 'lang/pl.json', 'lang/pt-BR.json', 'lang/ro.json', 'lang/ru.json', - 'lang/sk.json', - 'lang/ta.json', 'lang/tr.json', 'lang/uk.json', 'lang/zh-CN.json', - 'lang/zh-HK.json', 'lang/zh-TW.json' ]; const relativePathsNotToCache = [ @@ -69,16 +57,14 @@ const relativePathsNotToCache = [ ] self.addEventListener('install', function(event) { - // Perform install steps - console.log("Cache files for sw:", cacheVersion); + // Perform install steps event.waitUntil( caches.open(cacheTitle) .then(function(cache) { return cache .addAll(relativePathsToCache) .then(_ => { - console.log('All files cached for sw:', cacheVersion); - self.skipWaiting(); + console.log('All files cached.'); }); }) ); @@ -88,25 +74,20 @@ self.addEventListener('install', function(event) { const fromNetwork = (request, timeout) => new Promise((resolve, reject) => { const timeoutId = setTimeout(reject, timeout); - fetch(request, {cache: "no-store"}) + fetch(request) .then(response => { - if (response.redirected) { - throw new Error("Fetch is redirect. Abort usage and cache!"); - } - clearTimeout(timeoutId); resolve(response); - // Prevent requests that are in relativePathsNotToCache from being cached if (doNotCacheRequest(request)) return; - updateCache(request) + update(request) .then(() => console.log("Cache successfully updated for", request.url)) - .catch(err => console.log("Cache could not be updated for", request.url, err)); + .catch(reason => console.log("Cache could not be updated for", request.url, "Reason:", reason)); }) .catch(error => { // Handle any errors that occurred during the fetch - console.error(`Could not fetch ${request.url}.`); + console.error(`Could not fetch ${request.url}. Are you online?`); reject(error); }); }); @@ -128,16 +109,16 @@ const doNotCacheRequest = request => { }; // cache the current page to make it available for offline -const updateCache = request => new Promise((resolve, reject) => { +const update = request => new Promise((resolve, reject) => { + if (doNotCacheRequest(request)) { + reject("Url is specifically prevented from being cached in the serviceworker."); + return; + } caches .open(cacheTitle) .then(cache => fetch(request, {cache: "no-store"}) .then(response => { - if (response.redirected) { - throw new Error("Fetch is redirect. Abort usage and cache!"); - } - cache .put(request, response) .then(() => resolve()); @@ -146,19 +127,11 @@ const updateCache = request => new Promise((resolve, reject) => { ); }); -// general strategy when making a request: -// 1. Try to retrieve file from cache -// 2. If cache is not available: Fetch from network and update cache. -// This way, cached files are only updated if the cacheVersion is changed +// general strategy when making a request (eg if online try to fetch it +// from cache, if something fails fetch from network. Update cache everytime files are fetched. +// This way files should only be fetched if cacheVersion is changed self.addEventListener('fetch', function(event) { - const swOrigin = new URL(self.location.href).origin; - const requestOrigin = new URL(event.request.url).origin; - - if (swOrigin !== requestOrigin) { - // Do not handle requests from other origin - event.respondWith(fetch(event.request)); - } - else if (event.request.method === "POST") { + if (event.request.method === "POST") { // Requests related to Web Share Target. event.respondWith((async () => { const share_url = await evaluateRequestData(event.request); @@ -166,48 +139,39 @@ self.addEventListener('fetch', function(event) { })()); } else { - // Regular requests not related to Web Share Target: - // If request is excluded from cache -> respondWith fromNetwork - // else -> try fromCache first - event.respondWith( - doNotCacheRequest(event.request) - ? fromNetwork(event.request, 10000) - : fromCache(event.request) + // Regular requests not related to Web Share Target. + if (forceFetch) { + event.respondWith(fromNetwork(event.request, 10000)); + } + else { + event.respondWith( + fromCache(event.request) .then(rsp => { // if fromCache resolves to undefined fetch from network instead - if (!rsp) { - throw new Error("No match found."); - } - return rsp; + return rsp || fromNetwork(event.request, 10000); }) - .catch(error => { - console.error("Could not retrieve request from cache:", event.request.url, error); - return fromNetwork(event.request, 10000); - }) - ); + ); + } } }); // on activation, we clean up the previously registered service workers self.addEventListener('activate', evt => { - console.log("Activate sw:", cacheVersion); - evt.waitUntil(clients.claim()); - return evt.waitUntil( - caches - .keys() - .then(cacheNames => { - return Promise.all( - cacheNames.map(cacheName => { - if (cacheName !== cacheTitle) { - console.log("Delete cache:", cacheName); - return caches.delete(cacheName); - } - }) - ); - }) - ) -}); + return evt.waitUntil( + caches.keys() + .then(cacheNames => { + return Promise.all( + cacheNames.map(cacheName => { + if (cacheName !== cacheTitle) { + return caches.delete(cacheName); + } + }) + ); + }) + ) + } +); const evaluateRequestData = function (request) { return new Promise(async (resolve) => { diff --git a/public/styles/styles-main.css b/public/styles/styles-main.css index 32ffc46..9401d45 100644 --- a/public/styles/styles-main.css +++ b/public/styles/styles-main.css @@ -11,6 +11,10 @@ body { overflow-x: hidden; overscroll-behavior: none; overflow-y: hidden; + /* Only allow selection on message and pair key */ + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; transition: color 300ms; } @@ -587,6 +591,7 @@ x-dialog:not([show]) x-background { font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; + white-space: nowrap; cursor: pointer; user-select: none; background: inherit; @@ -691,6 +696,7 @@ button::-moz-focus-inner { /* Info Animation */ + #about { color: white; z-index: 32; @@ -746,11 +752,9 @@ button::-moz-focus-inner { height: var(--size); z-index: -1; background: var(--primary-color); - background-image: radial-gradient(circle at calc(50% - 36px), var(--primary-color) 0%, black 80%); + background-image: radial-gradient(circle at calc(50% - 36px), var(--accent-color) 0%, color-mix(in srgb, var(--accent-color) 40%, black) 80%); --crop-size: 0px; clip-path: circle(var(--crop-size)); - /* For clients < iOS 13.1 */ - -webkit-clip-path: circle(var(--crop-size)); } html:not([dir="rtl"]) #about x-background { @@ -898,7 +902,7 @@ x-peers:empty~x-instructions { @media screen and (min-height: 800px) { footer { - padding-bottom: 10px; + margin-bottom: 16px; } } @@ -908,13 +912,6 @@ x-peers:empty~x-instructions { } } -/* PWA Standalone styles */ -@media all and (display-mode: standalone) { - footer { - padding-bottom: 34px; - } -} - /* Constants */ :root {