diff --git a/composer.json b/composer.json index 7116c8be..77bb5874 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "ext-iconv": "*", "api-platform/core": "^2.7", "composer/package-versions-deprecated": "1.11.99.4", + "discord-php/http": "^10.2", "doctrine/annotations": "^1.0", "doctrine/doctrine-bundle": "^2.10", "doctrine/doctrine-fixtures-bundle": "^3.4", @@ -24,7 +25,7 @@ "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpdoc-parser": "^1.23", "ramsey/uuid-doctrine": "^1.6", - "restcord/restcord": "^0.5.0", + "react/async": "^4.1", "sensio/framework-extra-bundle": "^6.1", "spatie/calendar-links": "^1.2", "symfony/asset": "5.4.*", diff --git a/composer.lock b/composer.lock index d45bae00..b0b07f7f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3ba22e54414c35f4871e0f48b202e1f9", + "content-hash": "3b81e6b67679231f4f8e75e4587ff19d", "packages": [ { "name": "api-platform/core", @@ -303,6 +303,62 @@ ], "time": "2021-09-13T08:41:34+00:00" }, + { + "name": "discord-php/http", + "version": "v10.2.2", + "source": { + "type": "git", + "url": "https://github.com/discord-php/DiscordPHP-Http.git", + "reference": "dc1ddcd402435403b57f2f1024c5bd16140660f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/discord-php/DiscordPHP-Http/zipball/dc1ddcd402435403b57f2f1024c5bd16140660f1", + "reference": "dc1ddcd402435403b57f2f1024c5bd16140660f1", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "psr/log": "^1.1 || ^2.0 || ^3.0", + "react/http": "^1.2", + "react/promise": "^2.2" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.17", + "guzzlehttp/guzzle": "^6.0|^7.0", + "mockery/mockery": "^1.5", + "monolog/monolog": "^2.2", + "phpunit/phpunit": "^9.5", + "psy/psysh": "^0.10.6", + "react/async": "^4 || ^3" + }, + "suggest": { + "guzzlehttp/guzzle": "For alternative to ReactPHP/Http Browser" + }, + "type": "library", + "autoload": { + "psr-4": { + "Discord\\Http\\": "src/Discord", + "Tests\\Discord\\Http\\": "tests/Discord" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Cole", + "email": "david.cole1340@gmail.com" + } + ], + "description": "Handles HTTP requests to Discord servers", + "support": { + "issues": "https://github.com/discord-php/DiscordPHP-Http/issues", + "source": "https://github.com/discord-php/DiscordPHP-Http/tree/v10.2.2" + }, + "time": "2023-07-16T05:14:43+00:00" + }, { "name": "doctrine/annotations", "version": "1.14.3", @@ -2052,6 +2108,109 @@ }, "time": "2019-12-30T22:54:17+00:00" }, + { + "name": "evenement/evenement", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Evenement\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "support": { + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/v3.0.2" + }, + "time": "2023-08-08T05:53:35+00:00" + }, + { + "name": "fig/http-message-util", + "version": "1.1.5", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message-util.git", + "reference": "9d94dc0154230ac39e5bf89398b324a86f63f765" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message-util/zipball/9d94dc0154230ac39e5bf89398b324a86f63f765", + "reference": "9d94dc0154230ac39e5bf89398b324a86f63f765", + "shasum": "" + }, + "require": { + "php": "^5.3 || ^7.0 || ^8.0" + }, + "suggest": { + "psr/http-message": "The package containing the PSR-7 interfaces" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Fig\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Utility classes and constants for use with PSR-7 (psr/http-message)", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-message-util/issues", + "source": "https://github.com/php-fig/http-message-util/tree/1.1.5" + }, + "time": "2020-11-24T22:02:12+00:00" + }, { "name": "friendsofphp/proxy-manager-lts", "version": "v1.0.16", @@ -2200,63 +2359,6 @@ }, "time": "2021-12-15T08:51:04+00:00" }, - { - "name": "guzzlehttp/command", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/command.git", - "reference": "2aaa2521a8f8269d6f5dfc13fe2af12c76921034" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/command/zipball/2aaa2521a8f8269d6f5dfc13fe2af12c76921034", - "reference": "2aaa2521a8f8269d6f5dfc13fe2af12c76921034", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.2", - "guzzlehttp/promises": "~1.3", - "guzzlehttp/psr7": "~1.0", - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Command\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - } - ], - "description": "Provides the foundation for building command-based web service clients", - "support": { - "issues": "https://github.com/guzzle/command/issues", - "source": "https://github.com/guzzle/command/tree/1.0.0" - }, - "time": "2016-11-24T13:34:15+00:00" - }, { "name": "guzzlehttp/guzzle", "version": "6.5.8", @@ -2372,70 +2474,6 @@ ], "time": "2022-06-20T22:16:07+00:00" }, - { - "name": "guzzlehttp/guzzle-services", - "version": "1.1.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle-services.git", - "reference": "9e3abf20161cbf662d616cbb995f2811771759f7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle-services/zipball/9e3abf20161cbf662d616cbb995f2811771759f7", - "reference": "9e3abf20161cbf662d616cbb995f2811771759f7", - "shasum": "" - }, - "require": { - "guzzlehttp/command": "~1.0", - "guzzlehttp/guzzle": "^6.2", - "php": ">=5.5" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "gimler/guzzle-description-loader": "^0.0.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Command\\Guzzle\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - }, - { - "name": "Stefano Kowalke", - "email": "blueduck@mail.org", - "homepage": "https://github.com/konafets" - } - ], - "description": "Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.", - "support": { - "issues": "https://github.com/guzzle/guzzle-services/issues", - "source": "https://github.com/guzzle/guzzle-services/tree/1.1.3" - }, - "time": "2017-10-06T14:32:02+00:00" - }, { "name": "guzzlehttp/promises", "version": "1.5.3", @@ -3064,57 +3102,6 @@ }, "time": "2023-02-16T08:49:29+00:00" }, - { - "name": "netresearch/jsonmapper", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06", - "reference": "0d4d1b48d682a93b6bfedf60b88c7750e9cb0b06", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.6" - }, - "require-dev": { - "phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4", - "squizlabs/php_codesniffer": "~1.5" - }, - "type": "library", - "autoload": { - "psr-0": { - "JsonMapper": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "OSL-3.0" - ], - "authors": [ - { - "name": "Christian Weiske", - "email": "cweiske@cweiske.de", - "homepage": "http://github.com/cweiske/jsonmapper/", - "role": "Developer" - } - ], - "description": "Map nested JSON structures onto PHP classes", - "support": { - "email": "cweiske@cweiske.de", - "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/master" - }, - "time": "2019-08-15T19:41:25+00:00" - }, { "name": "paragonie/random_compat", "version": "v9.99.100", @@ -3977,40 +3964,35 @@ "time": "2022-11-03T19:30:26+00:00" }, { - "name": "restcord/restcord", - "version": "0.5.0", + "name": "react/async", + "version": "v4.1.0", "source": { "type": "git", - "url": "https://github.com/restcord/restcord.git", - "reference": "e79722fc74b15773a8b58237f678d004038f3529" + "url": "https://github.com/reactphp/async.git", + "reference": "b9641ac600b4b144e71a87dcf1be4d41dd3a3548" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/restcord/restcord/zipball/e79722fc74b15773a8b58237f678d004038f3529", - "reference": "e79722fc74b15773a8b58237f678d004038f3529", + "url": "https://api.github.com/repos/reactphp/async/zipball/b9641ac600b4b144e71a87dcf1be4d41dd3a3548", + "reference": "b9641ac600b4b144e71a87dcf1be4d41dd3a3548", "shasum": "" }, "require": { - "guzzlehttp/guzzle": "^6.3", - "guzzlehttp/guzzle-services": "^1.0", - "monolog/monolog": "^1.22|^2.0", - "netresearch/jsonmapper": "^1.4", - "php": "^7.3|^8.0", - "symfony/options-resolver": "^3.4|^4.4|^5.1" + "php": ">=8.1", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.8 || ^1.2.1" }, "require-dev": { - "beberlei/assert": "^2.7", - "gossi/php-code-generator": "^0.5.0", - "phpunit/phpunit": "^8.0|^9.0", - "symfony/console": "^2.6|^3.0|^4.0", - "symfony/process": "^2.6|^3.0|^4.0", - "symfony/var-dumper": "^2.6|^3.0|^4.0", - "twig/twig": "^1.20|^2.0" + "phpstan/phpstan": "1.10.18", + "phpunit/phpunit": "^9.5" }, "type": "library", "autoload": { + "files": [ + "src/functions_include.php" + ], "psr-4": { - "RestCord\\": "src/" + "React\\Async\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -4019,16 +4001,645 @@ ], "authors": [ { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com" + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async utilities and fibers for ReactPHP", + "keywords": [ + "async", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/async/issues", + "source": "https://github.com/reactphp/async/tree/v4.1.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" } ], - "description": "REST Library for the Discord API", + "time": "2023-06-22T14:10:50+00:00" + }, + { + "name": "react/cache", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/cache.git", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2022-11-30T15:59:55+00:00" + }, + { + "name": "react/dns", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "3be0fc8f1eb37d6875cd6f0c6c7d0be81435de9f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/3be0fc8f1eb37d6875cd6f0c6c7d0be81435de9f", + "reference": "3be0fc8f1eb37d6875cd6f0c6c7d0be81435de9f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.7 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^4.8.35", + "react/async": "^4 || ^3 || ^2", + "react/promise-timer": "^1.9" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.11.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-06-02T12:45:26+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "6e7e587714fff7a83dcc7025aee42ab3b265ae05" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/6e7e587714fff7a83dcc7025aee42ab3b265ae05", + "reference": "6e7e587714fff7a83dcc7025aee42ab3b265ae05", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "suggest": { + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.4.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-05-05T10:11:24+00:00" + }, + { + "name": "react/http", + "version": "v1.9.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/http.git", + "reference": "bb3154dbaf2dfe3f0467f956a05f614a69d5f1d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/http/zipball/bb3154dbaf2dfe3f0467f956a05f614a69d5f1d0", + "reference": "bb3154dbaf2dfe3f0467f956a05f614a69d5f1d0", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "fig/http-message-util": "^1.1", + "php": ">=5.3.0", + "psr/http-message": "^1.0", + "react/event-loop": "^1.2", + "react/promise": "^3 || ^2.3 || ^1.2.1", + "react/socket": "^1.12", + "react/stream": "^1.2", + "ringcentral/psr7": "^1.2" + }, + "require-dev": { + "clue/http-proxy-react": "^1.8", + "clue/reactphp-ssh-proxy": "^1.4", + "clue/socks-react": "^1.4", + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/async": "^4 || ^3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.9" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Http\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven, streaming HTTP client and server implementation for ReactPHP", + "keywords": [ + "async", + "client", + "event-driven", + "http", + "http client", + "http server", + "https", + "psr-7", + "reactphp", + "server", + "streaming" + ], + "support": { + "issues": "https://github.com/reactphp/http/issues", + "source": "https://github.com/reactphp/http/tree/v1.9.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-04-26T10:29:24+00:00" + }, + { + "name": "react/promise", + "version": "v2.10.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38", + "reference": "f913fb8cceba1e6644b7b90c4bfb678ed8a3ef38", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v2.10.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-05-02T15:15:43+00:00" + }, + { + "name": "react/socket", + "version": "v1.13.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "cff482bbad5848ecbe8b57da57e4e213b03619aa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/cff482bbad5848ecbe8b57da57e4e213b03619aa", + "reference": "cff482bbad5848ecbe8b57da57e4e213b03619aa", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.11", + "react/event-loop": "^1.2", + "react/promise": "^3 || ^2.6 || ^1.2.1", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/async": "^4 || ^3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.9" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.13.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-06-07T10:28:34+00:00" + }, + { + "name": "react/stream", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-06-16T10:52:11+00:00" + }, + { + "name": "ringcentral/psr7", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/ringcentral/psr7.git", + "reference": "360faaec4b563958b673fb52bbe94e37f14bc686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ringcentral/psr7/zipball/360faaec4b563958b673fb52bbe94e37f14bc686", + "reference": "360faaec4b563958b673fb52bbe94e37f14bc686", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "RingCentral\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ], "support": { - "issues": "https://github.com/restcord/restcord/issues", - "source": "https://github.com/restcord/restcord/tree/0.5.0" + "source": "https://github.com/ringcentral/psr7/tree/master" }, - "time": "2020-12-24T04:37:14+00:00" + "time": "2018-05-29T20:21:04+00:00" }, { "name": "sensio/framework-extra-bundle", diff --git a/src/Security/Authenticator/DiscordAuthenticator.php b/src/Security/Authenticator/DiscordAuthenticator.php index 94b247ff..9a1ac87e 100644 --- a/src/Security/Authenticator/DiscordAuthenticator.php +++ b/src/Security/Authenticator/DiscordAuthenticator.php @@ -12,17 +12,16 @@ use App\Security\Exception\RequiredRolesNotAssignedException; use App\Security\Exception\RoleNotFoundException; use App\Security\Exception\UserNotADiscordMemberException; -use App\Service\RestCord\DiscordClientFactory; +use App\Service\Discord\DiscordClientFactory; +use Discord\Http\Endpoint; +use Discord\Http\Exceptions\NotFoundException; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManagerInterface; -use GuzzleHttp\Command\Exception\CommandException; use KnpU\OAuth2ClientBundle\Client\ClientRegistry; use KnpU\OAuth2ClientBundle\Client\OAuth2ClientInterface; use KnpU\OAuth2ClientBundle\Security\Authenticator\SocialAuthenticator; use League\OAuth2\Client\Token\AccessToken; use Ramsey\Uuid\Uuid; -use RestCord\Model\Permissions\Role; -use RestCord\Model\User\Connection; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouterInterface; @@ -32,6 +31,8 @@ use Symfony\Component\Security\Core\User\UserProviderInterface; use Wohali\OAuth2\Client\Provider\DiscordResourceOwner; +use function React\Async\await; + /** * @see https://github.com/knpuniversity/oauth2-client-bundle */ @@ -49,7 +50,7 @@ public function __construct( private EntityManagerInterface $em, private RouterInterface $router, private DiscordClientFactory $discordClientFactory, - private int $discordServerId, + private string $discordServerId, private string $botToken, private array $requiredServerRoleNames ) { @@ -80,7 +81,7 @@ public function getUser($credentials, UserProviderInterface $userProvider): User /** @var DiscordResourceOwner $discordResourceOwner */ $discordResourceOwner = $this->getDiscordClient()->fetchUserFromToken($credentials); - $userId = (int) $discordResourceOwner->getId(); + $userId = $discordResourceOwner->getId(); $username = $discordResourceOwner->getUsername(); $fullUsername = $discordResourceOwner->getUsername().'#'.$discordResourceOwner->getDiscriminator(); $email = $discordResourceOwner->getEmail(); @@ -89,37 +90,42 @@ public function getUser($credentials, UserProviderInterface $userProvider): User $discordClientAsBot = $this->discordClientFactory->createBotClient($this->botToken); $discordClientAsUser = $this->discordClientFactory->createUserClient($credentials->getToken()); - $server = $discordClientAsBot->guild->getGuild(['guild.id' => $this->discordServerId]); + $serverResponse = await($discordClientAsBot->get( + Endpoint::bind(Endpoint::GUILD, $this->discordServerId) + )); try { - $userAsServerMember = $discordClientAsBot->guild->getGuildMember([ - 'guild.id' => $server->id, - 'user.id' => $userId, - ]); - } catch (CommandException $ex) { + $userAsServerMemberResponse = await($discordClientAsBot->get( + Endpoint::bind(Endpoint::GUILD_MEMBER, $serverResponse->id, $userId) + )); + } catch (NotFoundException $ex) { throw new UserNotADiscordMemberException( - sprintf('User "%s" is not a member of "%s" Discord server!', $username, $server->name) + sprintf('User "%s" is not a member of "%s" Discord server!', $username, $serverResponse->name) ); } // Collect IDs of required server roles by their names // This is needed as user object contains only IDs of roles assigned - $serverRoleIds = []; - $serverRoles = $discordClientAsBot->guild->getGuildRoles(['guild.id' => $server->id]); - foreach ($this->requiredServerRoleNames as $requiredServerRoleName) { - $serverRoleIds[] = $this->getRoleByName($serverRoles, $requiredServerRoleName)->id; - } + $serverRolesResponse = await($discordClientAsBot->get( + Endpoint::bind(Endpoint::GUILD_ROLES, $serverResponse->id) + )); + $serverRoleIds = array_map( + fn (string $requiredServerRoleName) => $this->getRoleIdByName($serverRolesResponse, $requiredServerRoleName), + $this->requiredServerRoleNames + ); // Check if user has at least one role assigned - if (0 === \count(array_intersect($serverRoleIds, $userAsServerMember->roles))) { + if (0 === \count(array_intersect($serverRoleIds, $userAsServerMemberResponse->roles))) { throw new RequiredRolesNotAssignedException( sprintf('User "%s" does not have required roles assigned!', $username) ); } - $userConnections = $discordClientAsUser->user->getUserConnections([]); - $steamConnection = (new ArrayCollection($userConnections)) - ->filter(static fn (Connection $connection) => ConnectionsEnum::STEAM === $connection->type) + $userConnectionsResponse = await($discordClientAsUser->get( + Endpoint::bind(Endpoint::USER_CURRENT_CONNECTIONS) + )); + $steamConnection = (new ArrayCollection($userConnectionsResponse)) + ->filter(static fn (\stdClass $connection) => ConnectionsEnum::STEAM === $connection->type) ->first() ; @@ -160,13 +166,13 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token, return new RedirectResponse($targetUrl); } - protected function getRoleByName(array $roles, string $roleName): Role + protected function getRoleIdByName(array $roles, string $roleName): string { - $rolesFound = (new ArrayCollection($roles))->filter(static fn (Role $role) => $role->name === $roleName); + $rolesFound = (new ArrayCollection($roles))->filter(static fn (\stdClass $role) => $role->name === $roleName); return match ($rolesFound->count()) { 0 => throw new RoleNotFoundException(sprintf('Role "%s" was not found!', $roleName)), - 1 => $rolesFound->first(), + 1 => $rolesFound->first()->id, default => throw new MultipleRolesFound(sprintf('Multiple roles found by given name "%s"!', $roleName)) }; } diff --git a/src/Service/Discord/DiscordClientFactory.php b/src/Service/Discord/DiscordClientFactory.php new file mode 100644 index 00000000..10e0ad8d --- /dev/null +++ b/src/Service/Discord/DiscordClientFactory.php @@ -0,0 +1,44 @@ +logger, + new React($loop) + ); + } + + public function createUserClient(string $userToken): Http + { + $token = sprintf('Bearer %s', $userToken); + $loop = Loop::get(); + + return new Http( + $token, + $loop, + $this->logger, + new React($loop) + ); + } +} diff --git a/src/Service/RestCord/DiscordClientFactory.php b/src/Service/RestCord/DiscordClientFactory.php deleted file mode 100644 index 5b8a8586..00000000 --- a/src/Service/RestCord/DiscordClientFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - $botToken, - 'tokenType' => 'Bot', - ]); - } - - public function createUserClient(string $userToken): DiscordClient - { - return new DiscordClient([ - 'token' => $userToken, - 'tokenType' => 'OAuth', - ]); - } -} diff --git a/tests/unit/Service/Discord/DiscordClientFactoryTest.php b/tests/unit/Service/Discord/DiscordClientFactoryTest.php new file mode 100644 index 00000000..e4492da2 --- /dev/null +++ b/tests/unit/Service/Discord/DiscordClientFactoryTest.php @@ -0,0 +1,52 @@ +createMock(LoggerInterface::class); + $discordClientFactory = new DiscordClientFactory($logger); + $discordClient = $discordClientFactory->createBotClient($token); + + $reflection = new \ReflectionClass($discordClient); + $tokenProperty = $reflection->getProperty('token'); + $tokenProperty->setAccessible(true); + $tokenPropertyValue = $tokenProperty->getValue($discordClient); + + static::assertSame(sprintf('Bot %s', $token), $tokenPropertyValue); + } + + /** + * @test + */ + public function createUserClient_validTokenType_returnsValidClient(): void + { + $token = 'some_token'; + $logger = $this->createMock(LoggerInterface::class); + $discordClientFactory = new DiscordClientFactory($logger); + $discordClient = $discordClientFactory->createUserClient($token); + + $reflection = new \ReflectionClass($discordClient); + $tokenProperty = $reflection->getProperty('token'); + $tokenProperty->setAccessible(true); + $tokenPropertyValue = $tokenProperty->getValue($discordClient); + + static::assertSame(sprintf('Bearer %s', $token), $tokenPropertyValue); + } +} diff --git a/tests/unit/Service/RestCord/DiscordClientFactoryTest.php b/tests/unit/Service/RestCord/DiscordClientFactoryTest.php deleted file mode 100644 index f49b57ef..00000000 --- a/tests/unit/Service/RestCord/DiscordClientFactoryTest.php +++ /dev/null @@ -1,51 +0,0 @@ -createBotClient($token); - - $reflection = new \ReflectionClass($discordClient); - $optionsProperty = $reflection->getProperty('options'); - $optionsProperty->setAccessible(true); - $optionsPropertyValue = $optionsProperty->getValue($discordClient); - - static::assertSame($token, $optionsPropertyValue['token']); - static::assertSame('Bot', $optionsPropertyValue['tokenType']); - } - - /** - * @test - */ - public function createUserClient_validTokenType_returnsValidClient(): void - { - $token = 'some_token'; - $discordClientFactory = new DiscordClientFactory(); - $discordClient = $discordClientFactory->createUserClient($token); - - $reflection = new \ReflectionClass($discordClient); - $optionsProperty = $reflection->getProperty('options'); - $optionsProperty->setAccessible(true); - $optionsPropertyValue = $optionsProperty->getValue($discordClient); - - static::assertSame($token, $optionsPropertyValue['token']); - static::assertSame('OAuth', $optionsPropertyValue['tokenType']); - } -}