From 0be39b6ccb93930f5ef6c799b5dd1cd7b5494c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Thu, 5 Dec 2024 16:38:12 +0100 Subject: [PATCH] Update packages. Change authenticator. --- .github/workflows/ci.yml | 4 - Dockerfile | 4 +- composer.lock | 465 +++++++++--------------- migrations/Version20241205135004.php | 38 ++ src/Entity/Event.php | 4 +- src/Entity/User.php | 5 +- src/Repository/UserEntityRepository.php | 25 ++ src/Security/NostrAuthenticator.php | 28 +- src/Service/NostrClient.php | 7 +- 9 files changed, 260 insertions(+), 320 deletions(-) create mode 100644 migrations/Version20241205135004.php create mode 100644 src/Repository/UserEntityRepository.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b0f691..58d24c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,18 +43,15 @@ jobs: run: curl -v --fail-with-body http://localhost - name: Check HTTPS reachability - if: false # Remove this line when the homepage will be configured, or change the path to check run: curl -vk --fail-with-body https://localhost - name: Check Mercure reachability run: curl -vkI --fail-with-body https://localhost/.well-known/mercure?topic=test - name: Create test database - if: false # Remove this line if Doctrine ORM is installed run: docker compose exec -T php bin/console -e test doctrine:database:create - name: Run migrations - if: false # Remove this line if Doctrine Migrations is installed run: docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction - name: Run PHPUnit @@ -62,7 +59,6 @@ jobs: run: docker compose exec -T php bin/phpunit - name: Doctrine Schema Validator - if: false # Remove this line if Doctrine ORM is installed run: docker compose exec -T php bin/console -e test doctrine:schema:validate lint: name: Docker Lint diff --git a/Dockerfile b/Dockerfile index 14841c2..fbdc52d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ file \ gettext \ git \ + libnss3-tools \ && rm -rf /var/lib/apt/lists/* RUN set -eux; \ @@ -41,8 +42,7 @@ ENV PHP_INI_SCAN_DIR=":$PHP_INI_DIR/app.conf.d" ###> recipes ### ###> doctrine/doctrine-bundle ### -RUN install-php-extensions pdo -RUN install-php-extensions pdo_pgsql +RUN install-php-extensions pdo pdo_pgsql ###< doctrine/doctrine-bundle ### ###< recipes ### diff --git a/composer.lock b/composer.lock index c1509d8..70a9369 100644 --- a/composer.lock +++ b/composer.lock @@ -1354,182 +1354,42 @@ }, "time": "2024-10-21T18:21:57+00:00" }, - { - "name": "fgrosse/phpasn1", - "version": "v2.5.0", - "source": { - "type": "git", - "url": "https://github.com/fgrosse/PHPASN1.git", - "reference": "42060ed45344789fb9f21f9f1864fc47b9e3507b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fgrosse/PHPASN1/zipball/42060ed45344789fb9f21f9f1864fc47b9e3507b", - "reference": "42060ed45344789fb9f21f9f1864fc47b9e3507b", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "php-coveralls/php-coveralls": "~2.0", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" - }, - "suggest": { - "ext-bcmath": "BCmath is the fallback extension for big integer calculations", - "ext-curl": "For loading OID information from the web if they have not bee defined statically", - "ext-gmp": "GMP is the preferred extension for big integer calculations", - "phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "FG\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Friedrich Große", - "email": "friedrich.grosse@gmail.com", - "homepage": "https://github.com/FGrosse", - "role": "Author" - }, - { - "name": "All contributors", - "homepage": "https://github.com/FGrosse/PHPASN1/contributors" - } - ], - "description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.", - "homepage": "https://github.com/FGrosse/PHPASN1", - "keywords": [ - "DER", - "asn.1", - "asn1", - "ber", - "binary", - "decoding", - "encoding", - "x.509", - "x.690", - "x509", - "x690" - ], - "support": { - "issues": "https://github.com/fgrosse/PHPASN1/issues", - "source": "https://github.com/fgrosse/PHPASN1/tree/v2.5.0" - }, - "abandoned": true, - "time": "2022-12-19T11:08:26+00:00" - }, - { - "name": "lcobucci/clock", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/lcobucci/clock.git", - "reference": "fb533e093fd61321bfcbac08b131ce805fe183d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/fb533e093fd61321bfcbac08b131ce805fe183d3", - "reference": "fb533e093fd61321bfcbac08b131ce805fe183d3", - "shasum": "" - }, - "require": { - "php": "^8.0", - "stella-maris/clock": "^0.1.4" - }, - "require-dev": { - "infection/infection": "^0.26", - "lcobucci/coding-standard": "^8.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^9.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Lcobucci\\Clock\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Luís Cobucci", - "email": "lcobucci@gmail.com" - } - ], - "description": "Yet another clock abstraction", - "support": { - "issues": "https://github.com/lcobucci/clock/issues", - "source": "https://github.com/lcobucci/clock/tree/2.2.0" - }, - "funding": [ - { - "url": "https://github.com/lcobucci", - "type": "github" - }, - { - "url": "https://www.patreon.com/lcobucci", - "type": "patreon" - } - ], - "time": "2022-04-19T19:34:17+00:00" - }, { "name": "lcobucci/jwt", - "version": "4.0.4", + "version": "5.4.2", "source": { "type": "git", "url": "https://github.com/lcobucci/jwt.git", - "reference": "55564265fddf810504110bd68ca311932324b0e9" + "reference": "ea1ce71cbf9741e445a5914e2f67cdbb484ff712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lcobucci/jwt/zipball/55564265fddf810504110bd68ca311932324b0e9", - "reference": "55564265fddf810504110bd68ca311932324b0e9", + "url": "https://api.github.com/repos/lcobucci/jwt/zipball/ea1ce71cbf9741e445a5914e2f67cdbb484ff712", + "reference": "ea1ce71cbf9741e445a5914e2f67cdbb484ff712", "shasum": "" }, "require": { - "ext-mbstring": "*", "ext-openssl": "*", - "lcobucci/clock": "^2.0", - "php": "^7.4 || ^8.0" + "ext-sodium": "*", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0", + "psr/clock": "^1.0" }, "require-dev": { - "infection/infection": "^0.20", - "lcobucci/coding-standard": "^6.0", - "mikey179/vfsstream": "^1.6", - "phpbench/phpbench": "^0.17", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12", - "phpstan/phpstan-deprecation-rules": "^0.12", - "phpstan/phpstan-phpunit": "^0.12", - "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/php-invoker": "^3.1", - "phpunit/phpunit": "^9.4" + "infection/infection": "^0.29", + "lcobucci/clock": "^3.2", + "lcobucci/coding-standard": "^11.0", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.10.7", + "phpstan/phpstan-deprecation-rules": "^1.1.3", + "phpstan/phpstan-phpunit": "^1.3.10", + "phpstan/phpstan-strict-rules": "^1.5.0", + "phpunit/phpunit": "^11.1" }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } + "suggest": { + "lcobucci/clock": ">= 3.2" }, + "type": "library", "autoload": { "psr-4": { "Lcobucci\\JWT\\": "src" @@ -1553,7 +1413,7 @@ ], "support": { "issues": "https://github.com/lcobucci/jwt/issues", - "source": "https://github.com/lcobucci/jwt/tree/4.0.4" + "source": "https://github.com/lcobucci/jwt/tree/5.4.2" }, "funding": [ { @@ -1565,7 +1425,7 @@ "type": "patreon" } ], - "time": "2021-09-28T19:18:28+00:00" + "time": "2024-11-07T12:54:35+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -2634,65 +2494,18 @@ }, "time": "2024-01-09T14:57:04+00:00" }, - { - "name": "stella-maris/clock", - "version": "0.1.7", - "source": { - "type": "git", - "url": "https://github.com/stella-maris-solutions/clock.git", - "reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/stella-maris-solutions/clock/zipball/fa23ce16019289a18bb3446fdecd45befcdd94f8", - "reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8", - "shasum": "" - }, - "require": { - "php": "^7.0|^8.0", - "psr/clock": "^1.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "StellaMaris\\Clock\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andreas Heigl", - "role": "Maintainer" - } - ], - "description": "A pre-release of the proposed PSR-20 Clock-Interface", - "homepage": "https://gitlab.com/stella-maris/clock", - "keywords": [ - "clock", - "datetime", - "point in time", - "psr20" - ], - "support": { - "source": "https://github.com/stella-maris-solutions/clock/tree/0.1.7" - }, - "time": "2022-11-25T16:15:06+00:00" - }, { "name": "swentel/nostr-php", - "version": "1.5.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/nostrver-se/nostr-php.git", - "reference": "93091fae55173b8e0776199a8de08014441a15d4" + "reference": "cca30f99b07d6f2d1d645f670ac56d3c36b65bd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nostrver-se/nostr-php/zipball/93091fae55173b8e0776199a8de08014441a15d4", - "reference": "93091fae55173b8e0776199a8de08014441a15d4", + "url": "https://api.github.com/repos/nostrver-se/nostr-php/zipball/cca30f99b07d6f2d1d645f670ac56d3c36b65bd1", + "reference": "cca30f99b07d6f2d1d645f670ac56d3c36b65bd1", "shasum": "" }, "require": { @@ -2702,7 +2515,7 @@ "php": ">=8.1 <8.5", "phrity/websocket": "^3.0", "simplito/elliptic-php": "^1.0", - "uma/phpecc": "^0.1.3" + "uma/phpecc": "^0.2.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.51", @@ -2744,9 +2557,9 @@ "chat": "https://t.me/nostr_php", "issue": "https://github.com/swentel/nostr-php/issues", "issues": "https://github.com/nostrver-se/nostr-php/issues", - "source": "https://github.com/nostrver-se/nostr-php/tree/1.5.1" + "source": "https://github.com/nostrver-se/nostr-php/tree/1.5.2" }, - "time": "2024-11-24T22:06:24+00:00" + "time": "2024-12-05T09:03:53+00:00" }, { "name": "symfony/asset", @@ -2898,16 +2711,16 @@ }, { "name": "symfony/cache", - "version": "v7.1.7", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "23b61c9592ee72233c31625f0ae805dd1571e928" + "reference": "18e0ba45a50032aa53dfebf830ec2980bb131591" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/23b61c9592ee72233c31625f0ae805dd1571e928", - "reference": "23b61c9592ee72233c31625f0ae805dd1571e928", + "url": "https://api.github.com/repos/symfony/cache/zipball/18e0ba45a50032aa53dfebf830ec2980bb131591", + "reference": "18e0ba45a50032aa53dfebf830ec2980bb131591", "shasum": "" }, "require": { @@ -2975,7 +2788,7 @@ "psr6" ], "support": { - "source": "https://github.com/symfony/cache/tree/v7.1.7" + "source": "https://github.com/symfony/cache/tree/v7.1.9" }, "funding": [ { @@ -2991,20 +2804,20 @@ "type": "tidelift" } ], - "time": "2024-11-05T15:34:55+00:00" + "time": "2024-11-20T10:42:04+00:00" }, { "name": "symfony/cache-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/cache-contracts.git", - "reference": "df6a1a44c890faded49a5fca33c2d5c5fd3c2197" + "reference": "15a4f8e5cd3bce9aeafc882b1acab39ec8de2c1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/df6a1a44c890faded49a5fca33c2d5c5fd3c2197", - "reference": "df6a1a44c890faded49a5fca33c2d5c5fd3c2197", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/15a4f8e5cd3bce9aeafc882b1acab39ec8de2c1b", + "reference": "15a4f8e5cd3bce9aeafc882b1acab39ec8de2c1b", "shasum": "" }, "require": { @@ -3051,7 +2864,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/cache-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/cache-contracts/tree/v3.5.1" }, "funding": [ { @@ -3067,7 +2880,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/clock", @@ -3460,16 +3273,16 @@ }, { "name": "symfony/doctrine-bridge", - "version": "v7.1.6", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/doctrine-bridge.git", - "reference": "3fcfb37b738def92757b6ac5365a3147b2e2dd36" + "reference": "893cc4fa0f218d6e88efbe58397e2b42167648e1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/doctrine-bridge/zipball/3fcfb37b738def92757b6ac5365a3147b2e2dd36", - "reference": "3fcfb37b738def92757b6ac5365a3147b2e2dd36", + "url": "https://api.github.com/repos/symfony/doctrine-bridge/zipball/893cc4fa0f218d6e88efbe58397e2b42167648e1", + "reference": "893cc4fa0f218d6e88efbe58397e2b42167648e1", "shasum": "" }, "require": { @@ -3499,7 +3312,7 @@ }, "require-dev": { "doctrine/collections": "^1.0|^2.0", - "doctrine/data-fixtures": "^1.1", + "doctrine/data-fixtures": "^1.1|^2", "doctrine/dbal": "^3.6|^4", "doctrine/orm": "^2.15|^3", "psr/log": "^1|^2|^3", @@ -3548,7 +3361,7 @@ "description": "Provides integration for Doctrine with various Symfony components", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/doctrine-bridge/tree/v7.1.6" + "source": "https://github.com/symfony/doctrine-bridge/tree/v7.1.9" }, "funding": [ { @@ -3564,20 +3377,20 @@ "type": "tidelift" } ], - "time": "2024-10-18T09:42:06+00:00" + "time": "2024-11-25T12:02:18+00:00" }, { "name": "symfony/dotenv", - "version": "v7.1.6", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/dotenv.git", - "reference": "56a10f3032a6c2f085b13bc429e9d78a2c895dc4" + "reference": "245d1afe223664d2276afb75177d8988c328fb78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dotenv/zipball/56a10f3032a6c2f085b13bc429e9d78a2c895dc4", - "reference": "56a10f3032a6c2f085b13bc429e9d78a2c895dc4", + "url": "https://api.github.com/repos/symfony/dotenv/zipball/245d1afe223664d2276afb75177d8988c328fb78", + "reference": "245d1afe223664d2276afb75177d8988c328fb78", "shasum": "" }, "require": { @@ -3622,7 +3435,7 @@ "environment" ], "support": { - "source": "https://github.com/symfony/dotenv/tree/v7.1.6" + "source": "https://github.com/symfony/dotenv/tree/v7.1.9" }, "funding": [ { @@ -3638,7 +3451,7 @@ "type": "tidelift" } ], - "time": "2024-09-28T11:14:12+00:00" + "time": "2024-11-27T11:17:28+00:00" }, { "name": "symfony/error-handler", @@ -4316,23 +4129,23 @@ }, { "name": "symfony/http-client", - "version": "v7.1.8", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/http-client.git", - "reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a" + "reference": "2ec49720a38a8041673ba4c42512bfd845218c56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-client/zipball/c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", - "reference": "c30d91a1deac0dc3ed5e604683cf2e1dfc635b8a", + "url": "https://api.github.com/repos/symfony/http-client/zipball/2ec49720a38a8041673ba4c42512bfd845218c56", + "reference": "2ec49720a38a8041673ba4c42512bfd845218c56", "shasum": "" }, "require": { "php": ">=8.2", "psr/log": "^1|^2|^3", "symfony/deprecation-contracts": "^2.5|^3", - "symfony/http-client-contracts": "^3.4.1", + "symfony/http-client-contracts": "~3.4.3|^3.5.1", "symfony/service-contracts": "^2.5|^3" }, "conflict": { @@ -4390,7 +4203,7 @@ "http" ], "support": { - "source": "https://github.com/symfony/http-client/tree/v7.1.8" + "source": "https://github.com/symfony/http-client/tree/v7.1.9" }, "funding": [ { @@ -4406,7 +4219,7 @@ "type": "tidelift" } ], - "time": "2024-11-13T13:40:27+00:00" + "time": "2024-11-27T11:52:45+00:00" }, { "name": "symfony/http-client-contracts", @@ -5629,16 +5442,16 @@ }, { "name": "symfony/routing", - "version": "v7.1.6", + "version": "v7.1.9", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "66a2c469f6c22d08603235c46a20007c0701ea0a" + "reference": "a27bb8e0cc3ca4baf17159d053910c9736c3aa4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/66a2c469f6c22d08603235c46a20007c0701ea0a", - "reference": "66a2c469f6c22d08603235c46a20007c0701ea0a", + "url": "https://api.github.com/repos/symfony/routing/zipball/a27bb8e0cc3ca4baf17159d053910c9736c3aa4c", + "reference": "a27bb8e0cc3ca4baf17159d053910c9736c3aa4c", "shasum": "" }, "require": { @@ -5690,7 +5503,7 @@ "url" ], "support": { - "source": "https://github.com/symfony/routing/tree/v7.1.6" + "source": "https://github.com/symfony/routing/tree/v7.1.9" }, "funding": [ { @@ -5706,7 +5519,7 @@ "type": "tidelift" } ], - "time": "2024-10-01T08:31:23+00:00" + "time": "2024-11-13T16:12:35+00:00" }, { "name": "symfony/runtime", @@ -6890,20 +6703,21 @@ }, { "name": "symfony/ux-live-component", - "version": "v2.21.0", + "version": "v2.22.0", "source": { "type": "git", "url": "https://github.com/symfony/ux-live-component.git", - "reference": "1cc963a50a31a8ca92fbd145b29b27231b199b1b" + "reference": "2df6a25f25788864e65cb8812d85e14ef80b6b44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-live-component/zipball/1cc963a50a31a8ca92fbd145b29b27231b199b1b", - "reference": "1cc963a50a31a8ca92fbd145b29b27231b199b1b", + "url": "https://api.github.com/repos/symfony/ux-live-component/zipball/2df6a25f25788864e65cb8812d85e14ef80b6b44", + "reference": "2df6a25f25788864e65cb8812d85e14ef80b6b44", "shasum": "" }, "require": { "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3.0", "symfony/property-access": "^5.4.5|^6.0|^7.0", "symfony/stimulus-bundle": "^2.9", "symfony/ux-twig-component": "^2.8", @@ -6936,8 +6750,8 @@ "type": "symfony-bundle", "extra": { "thanks": { - "name": "symfony/ux", - "url": "https://github.com/symfony/ux" + "url": "https://github.com/symfony/ux", + "name": "symfony/ux" } }, "autoload": { @@ -6963,7 +6777,7 @@ "twig" ], "support": { - "source": "https://github.com/symfony/ux-live-component/tree/v2.21.0" + "source": "https://github.com/symfony/ux-live-component/tree/v2.22.0" }, "funding": [ { @@ -6979,20 +6793,20 @@ "type": "tidelift" } ], - "time": "2024-10-15T10:36:54+00:00" + "time": "2024-11-29T15:31:04+00:00" }, { "name": "symfony/ux-twig-component", - "version": "v2.21.0", + "version": "v2.22.0", "source": { "type": "git", "url": "https://github.com/symfony/ux-twig-component.git", - "reference": "5b60b239fffcb04fc8bdb2a5a4001d19442d575d" + "reference": "03177a494399fbdcbb1f5f2aee017ccf8df581d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/5b60b239fffcb04fc8bdb2a5a4001d19442d575d", - "reference": "5b60b239fffcb04fc8bdb2a5a4001d19442d575d", + "url": "https://api.github.com/repos/symfony/ux-twig-component/zipball/03177a494399fbdcbb1f5f2aee017ccf8df581d9", + "reference": "03177a494399fbdcbb1f5f2aee017ccf8df581d9", "shasum": "" }, "require": { @@ -7019,8 +6833,8 @@ "type": "symfony-bundle", "extra": { "thanks": { - "name": "symfony/ux", - "url": "https://github.com/symfony/ux" + "url": "https://github.com/symfony/ux", + "name": "symfony/ux" } }, "autoload": { @@ -7046,7 +6860,7 @@ "twig" ], "support": { - "source": "https://github.com/symfony/ux-twig-component/tree/v2.21.0" + "source": "https://github.com/symfony/ux-twig-component/tree/v2.22.0" }, "funding": [ { @@ -7062,7 +6876,7 @@ "type": "tidelift" } ], - "time": "2024-10-05T22:11:16+00:00" + "time": "2024-11-23T06:59:34+00:00" }, { "name": "symfony/var-dumper", @@ -7379,7 +7193,7 @@ }, { "name": "twig/extra-bundle", - "version": "v3.15.0", + "version": "v3.16.0", "source": { "type": "git", "url": "https://github.com/twigphp/twig-extra-bundle.git", @@ -7437,7 +7251,7 @@ "twig" ], "support": { - "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.15.0" + "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.16.0" }, "funding": [ { @@ -7453,16 +7267,16 @@ }, { "name": "twig/twig", - "version": "v3.15.0", + "version": "v3.16.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "2d5b3964cc21d0188633d7ddce732dc8e874db02" + "reference": "475ad2dc97d65d8631393e721e7e44fb544f0561" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/2d5b3964cc21d0188633d7ddce732dc8e874db02", - "reference": "2d5b3964cc21d0188633d7ddce732dc8e874db02", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/475ad2dc97d65d8631393e721e7e44fb544f0561", + "reference": "475ad2dc97d65d8631393e721e7e44fb544f0561", "shasum": "" }, "require": { @@ -7473,6 +7287,7 @@ "symfony/polyfill-php81": "^1.29" }, "require-dev": { + "phpstan/phpstan": "^2.0", "psr/container": "^1.0|^2.0", "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" }, @@ -7516,7 +7331,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.15.0" + "source": "https://github.com/twigphp/Twig/tree/v3.16.0" }, "funding": [ { @@ -7528,34 +7343,108 @@ "type": "tidelift" } ], - "time": "2024-11-17T15:59:19+00:00" + "time": "2024-11-29T08:27:05+00:00" + }, + { + "name": "uma/phpasn1", + "version": "v2.5.1", + "source": { + "type": "git", + "url": "https://github.com/1ma/PHPASN1.git", + "reference": "dd805d3157ddc90515ee13562a9bb241c68f4f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/1ma/PHPASN1/zipball/dd805d3157ddc90515ee13562a9bb241c68f4f88", + "reference": "dd805d3157ddc90515ee13562a9bb241c68f4f88", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.0", + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "ext-bcmath": "BCmath is the fallback extension for big integer calculations", + "ext-curl": "For loading OID information from the web if they have not bee defined statically", + "ext-gmp": "GMP is the preferred extension for big integer calculations", + "phpseclib/bcmath_compat": "BCmath polyfill for servers where neither GMP nor BCmath is available" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "FG\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Friedrich Große", + "email": "friedrich.grosse@gmail.com", + "homepage": "https://github.com/FGrosse", + "role": "Author" + }, + { + "name": "All contributors", + "homepage": "https://github.com/FGrosse/PHPASN1/contributors" + } + ], + "description": "A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.", + "homepage": "https://github.com/FGrosse/PHPASN1", + "keywords": [ + "DER", + "asn.1", + "asn1", + "ber", + "binary", + "decoding", + "encoding", + "x.509", + "x.690", + "x509", + "x690" + ], + "support": { + "source": "https://github.com/1ma/PHPASN1/tree/v2.5.1" + }, + "time": "2024-11-29T17:34:36+00:00" }, { "name": "uma/phpecc", - "version": "v0.1.3", + "version": "v0.2.0", "source": { "type": "git", "url": "https://github.com/1ma/phpecc.git", - "reference": "a83dfa5fd6801fcc029364a555cec584d351c481" + "reference": "8952716a7378a829b9ce50535e913f6592664173" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/1ma/phpecc/zipball/a83dfa5fd6801fcc029364a555cec584d351c481", - "reference": "a83dfa5fd6801fcc029364a555cec584d351c481", + "url": "https://api.github.com/repos/1ma/phpecc/zipball/8952716a7378a829b9ce50535e913f6592664173", + "reference": "8952716a7378a829b9ce50535e913f6592664173", "shasum": "" }, "require": { "ext-gmp": "*", - "fgrosse/phpasn1": "^2.0", - "php": "^8.0" + "php": "^8.0", + "uma/phpasn1": "^2.5.1" }, "replace": { "mdanter/ecc": "1.0.0" }, "require-dev": { - "phpunit/phpunit": "^6.0||^8.0||^9.0", + "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^2.0", - "symfony/yaml": "^2.6|^3.0" + "symfony/yaml": "^6.4 || ^7.0" }, "type": "library", "autoload": { @@ -7611,9 +7500,9 @@ "secp256r1" ], "support": { - "source": "https://github.com/1ma/phpecc/tree/v0.1.3" + "source": "https://github.com/1ma/phpecc/tree/v0.2.0" }, - "time": "2024-02-27T15:58:47+00:00" + "time": "2024-11-29T17:59:36+00:00" }, { "name": "webmozart/assert", diff --git a/migrations/Version20241205135004.php b/migrations/Version20241205135004.php new file mode 100644 index 0000000..629ed19 --- /dev/null +++ b/migrations/Version20241205135004.php @@ -0,0 +1,38 @@ +addSql('DELETE FROM app_user + WHERE id NOT IN ( + SELECT MIN(id) + FROM app_user + GROUP BY npub + );'); + // this up() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE UNIQUE INDEX UNIQ_88BDF3E95FB8BABB ON app_user (npub)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP INDEX UNIQ_88BDF3E95FB8BABB'); + } +} diff --git a/src/Entity/Event.php b/src/Entity/Event.php index cb23d48..06bc1f4 100644 --- a/src/Entity/Event.php +++ b/src/Entity/Event.php @@ -6,11 +6,11 @@ class Event { private string $id; private int $kind = 0; - private string $pubkey; + private string $pubkey = ''; private string $content = ''; private int $created_at = 0; private array $tags = []; - private string $sig; + private string $sig = ''; public function getId(): string { diff --git a/src/Entity/User.php b/src/Entity/User.php index f9ec041..37f61d2 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -2,6 +2,7 @@ namespace App\Entity; +use App\Repository\UserEntityRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Security\Core\User\UserInterface; @@ -9,7 +10,7 @@ use Symfony\Component\Security\Core\User\UserInterface; /** * Entity storing local user representations */ -#[ORM\Entity] +#[ORM\Entity(repositoryClass: UserEntityRepository::class)] #[ORM\Table(name: "app_user")] class User implements UserInterface { @@ -18,7 +19,7 @@ class User implements UserInterface #[ORM\Column] private ?int $id = null; - #[ORM\Column] + #[ORM\Column(unique: true)] private ?string $npub = null; #[ORM\Column] diff --git a/src/Repository/UserEntityRepository.php b/src/Repository/UserEntityRepository.php new file mode 100644 index 0000000..4f0069a --- /dev/null +++ b/src/Repository/UserEntityRepository.php @@ -0,0 +1,25 @@ +findOneBy(['npub' => $user->getNpub()]); + + if (!$entity) { + $this->_em->persist($user); + } + + return $entity; + } +} diff --git a/src/Security/NostrAuthenticator.php b/src/Security/NostrAuthenticator.php index 1465c17..49c6179 100644 --- a/src/Security/NostrAuthenticator.php +++ b/src/Security/NostrAuthenticator.php @@ -5,6 +5,7 @@ namespace App\Security; use App\Entity\Event; use App\Service\NostrClient; use Doctrine\ORM\EntityManagerInterface; +use Mdanter\Ecc\Crypto\Signature\SchnorrSignature; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; @@ -20,7 +21,7 @@ use Symfony\Component\Serializer\Serializer; class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAuthenticatorInterface { - public function __construct(private readonly NostrClient $nostrClient, private readonly EntityManagerInterface $entityManager) + public function __construct(private readonly NostrClient $nostrClient) { } @@ -42,27 +43,26 @@ class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAut $eventStr = base64_decode(substr($authHeader, 6), true); $encoders = [new JsonEncoder()]; $normalizers = [new ObjectNormalizer()]; - $serializer = new Serializer($normalizers, $encoders); /** @var Event $event */ $event = $serializer->deserialize($eventStr, Event::class, 'json'); if (time() > $event->getCreatedAt() + 60) { throw new AuthenticationException('Expired'); } - // TODO enable validity check after bug is fixed - // $validity = (new SchnorrSignature())->verify($event->getPubkey(), $event->getSig(), $event->getId()); - // pretend all is well - $validity = true; + $validity = (new SchnorrSignature())->verify($event->getPubkey(), $event->getSig(), $event->getId()); if (!$validity) { throw new AuthenticationException('Invalid Authorization header'); } + // default, in case this is a plain key with no metadata event + $user = new \App\Entity\User(); + $user->setNpub($event->getPubkey()); + try { - $user = $this->fetchUser($event->getPubkey()); + $this->nostrClient->getMetadata([$event->getPubkey()]); } catch (\Exception) { // even if the user metadata not found, if sig is valid, login the pubkey - $user = new \App\Entity\User(); - $user->setNpub($event->getPubkey()); + // TODO log? } return new SelfValidatingPassport( @@ -80,16 +80,6 @@ class NostrAuthenticator extends AbstractAuthenticator implements InteractiveAut return null; } - /** - * - * @throws \Exception - */ - private function fetchUser(string $publicKey): \App\Entity\User - { - $this->nostrClient->getMetadata([$publicKey]); - return $this->entityManager->getRepository(\App\Entity\User::class)->findOneBy(['npub' => $publicKey]); - } - public function isInteractive(): bool { return true; diff --git a/src/Service/NostrClient.php b/src/Service/NostrClient.php index 616e992..7e433e0 100644 --- a/src/Service/NostrClient.php +++ b/src/Service/NostrClient.php @@ -6,6 +6,7 @@ use App\Entity\Article; use App\Entity\User; use App\Enum\KindsEnum; use App\Factory\ArticleFactory; +use App\Repository\UserEntityRepository; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use swentel\nostr\Filter\Filter; @@ -20,6 +21,7 @@ use Symfony\Component\Serializer\SerializerInterface; class NostrClient { public function __construct(private readonly EntityManagerInterface $entityManager, + private readonly UserEntityRepository $userEntityRepository, private readonly ArticleFactory $articleFactory, private readonly SerializerInterface $serializer, private readonly LoggerInterface $logger) @@ -37,8 +39,7 @@ class NostrClient $filter = new Filter(); $filter->setKinds([KindsEnum::LONGFORM]); // TODO make filters configurable - $filter->setSince(strtotime('-1 year')); // - $filter->setUntil(strtotime('-11 months')); // + $filter->setSince(strtotime('-1 day')); // $requestMessage = new RequestMessage($subscriptionId, [$filter]); // TODO make relays configurable $relays = new RelaySet(); @@ -115,7 +116,7 @@ class NostrClient try { $this->logger->info('Saving user', ['user' => $user]); - $this->entityManager->persist($user); + $this->userEntityRepository->findOrCreateByUniqueField($user); $this->entityManager->flush(); } catch (\Exception $e) { $this->logger->error($e->getMessage());