diff --git a/LICENCE b/LICENCE index bec90e2..5ec1380 100644 --- a/LICENCE +++ b/LICENCE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2023, flashwave +Copyright (c) 2020-2024, flashwave All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/composer.lock b/composer.lock index 7c75cef..20983f9 100644 --- a/composer.lock +++ b/composer.lock @@ -12,7 +12,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/index.git", - "reference": "e31781c69f0b13fe251771c8e7e529222630a44f" + "reference": "9d5b050b8928435416a7efbebe2a19ae8e626224" }, "require": { "ext-mbstring": "*", @@ -50,7 +50,7 @@ ], "description": "Composer package for the common library for my projects.", "homepage": "https://railgun.sh/index", - "time": "2023-11-20T19:01:19+00:00" + "time": "2024-03-28T23:27:04+00:00" }, { "name": "flashwave/syokuhou", @@ -58,7 +58,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/syokuhou.git", - "reference": "fdf3c38cc216bf7024af331cbe1758532355c22f" + "reference": "c1fe9371ada20fcea51c225cc53b9ceae4642bc4" }, "require": { "flashwave/index": "dev-master", @@ -89,7 +89,7 @@ ], "description": "Configuration library for PHP.", "homepage": "https://railgun.sh/syokuhou", - "time": "2023-11-20T19:10:04+00:00" + "time": "2024-01-04T02:12:49+00:00" }, { "name": "guzzlehttp/psr7", @@ -209,16 +209,16 @@ }, { "name": "jean85/pretty-package-versions", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" + "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", - "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4", + "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4", "shasum": "" }, "require": { @@ -226,9 +226,9 @@ "php": "^7.1|^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17", + "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", - "phpstan/phpstan": "^0.12.66", + "phpstan/phpstan": "^1.4", "phpunit/phpunit": "^7.5|^8.5|^9.4", "vimeo/psalm": "^4.3" }, @@ -262,9 +262,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.6" }, - "time": "2021-10-08T21:21:46+00:00" + "time": "2024-03-08T09:58:59+00:00" }, { "name": "psr/http-factory", @@ -525,16 +525,16 @@ }, { "name": "sentry/sentry", - "version": "4.1.0", + "version": "4.6.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "89666f297891ff937fceb2f3d1fb967a6848cf37" + "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/89666f297891ff937fceb2f3d1fb967a6848cf37", - "reference": "89666f297891ff937fceb2f3d1fb967a6848cf37", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/5a94184175e5830b589bf923da8c9c3af2c0f409", + "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409", "shasum": "" }, "require": { @@ -558,7 +558,7 @@ "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", "phpunit/phpunit": "^8.5.14|^9.4", - "symfony/phpunit-bridge": "^5.2|^6.0", + "symfony/phpunit-bridge": "^5.2|^6.0|^7.0", "vimeo/psalm": "^4.17" }, "suggest": { @@ -598,7 +598,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/4.1.0" + "source": "https://github.com/getsentry/sentry-php/tree/4.6.1" }, "funding": [ { @@ -610,7 +610,7 @@ "type": "custom" } ], - "time": "2023-12-04T12:41:21+00:00" + "time": "2024-03-08T08:18:09+00:00" }, { "name": "symfony/deprecation-contracts", @@ -750,16 +750,16 @@ "packages-dev": [ { "name": "phpstan/phpstan", - "version": "1.10.50", + "version": "1.10.66", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4" + "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/06a98513ac72c03e8366b5a0cb00750b487032e4", - "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", + "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", "shasum": "" }, "require": { @@ -808,7 +808,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T10:59:42+00:00" + "time": "2024-03-28T16:17:31+00:00" } ], "aliases": [], @@ -821,5 +821,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/public/index.html b/public/index.html index b2e537a..9cd3ff3 100644 --- a/public/index.html +++ b/public/index.html @@ -56,7 +56,7 @@ diff --git a/src/Auth/AuthRoutes.php b/src/Auth/AuthRoutes.php index 15a5cc8..ca96874 100644 --- a/src/Auth/AuthRoutes.php +++ b/src/Auth/AuthRoutes.php @@ -1,8 +1,7 @@ getHeaderLine('Authorization'); if(empty($auth)) { diff --git a/src/Auth/ChatAuth.php b/src/Auth/ChatAuth.php index 781c1d6..790d9d4 100644 --- a/src/Auth/ChatAuth.php +++ b/src/Auth/ChatAuth.php @@ -4,7 +4,7 @@ namespace EEPROM\Auth; use stdClass; final class ChatAuth { - public static function attempt(string $endPoint, string $secret, string $cookie): object { + public static function attempt(string $endPoint, string $secret, string $cookie): stdClass { if(!empty($cookie)) { $method = 'Misuzu'; $signature = sprintf('verify#%s#%s#%s', $method, $cookie, $_SERVER['REMOTE_ADDR']); diff --git a/src/LandingRoutes.php b/src/LandingRoutes.php index 08cfcfc..ef10897 100644 --- a/src/LandingRoutes.php +++ b/src/LandingRoutes.php @@ -2,21 +2,20 @@ namespace EEPROM; use stdClass; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,RouteHandler}; class LandingRoutes extends RouteHandler { public function __construct( private DatabaseContext $dbCtx ) {} - #[Route('GET', '/')] + #[HttpGet('/')] public function getIndex($response) { $response->accelRedirect('/index.html'); $response->setContentType('text/html; charset=utf-8'); } - #[Route('GET', '/stats.json')] + #[HttpGet('/stats.json')] public function getStats() { $dbConn = $this->dbCtx->getConnection(); @@ -40,7 +39,7 @@ class LandingRoutes extends RouteHandler { return $stats; } - #[Route('GET', '/eeprom.js')] + #[HttpGet('/eeprom.js')] public function getEepromJs($response) { $response->accelRedirect('/scripts/eepromv1.js'); $response->setContentType('application/javascript; charset=utf-8'); diff --git a/src/RoutingContext.php b/src/RoutingContext.php index b5153c8..d4cc2a2 100644 --- a/src/RoutingContext.php +++ b/src/RoutingContext.php @@ -1,17 +1,15 @@ router = new HttpFx; + $this->router = new HttpRouter; $this->router->use('/', $this->middleware(...)); } diff --git a/src/Uploads/UploadsRoutes.php b/src/Uploads/UploadsRoutes.php index 5322b93..c161a5f 100644 --- a/src/Uploads/UploadsRoutes.php +++ b/src/Uploads/UploadsRoutes.php @@ -2,9 +2,7 @@ namespace EEPROM\Uploads; use RuntimeException; -use Index\Routing\IRouter; -use Index\Routing\IRouteHandler; -use Index\Routing\Route; +use Index\Http\Routing\{HandlerAttribute,HttpDelete,HttpGet,HttpOptions,HttpPost,IRouter,IRouteHandler}; use EEPROM\Apps\AppsContext; use EEPROM\Auth\AuthInfo; use EEPROM\Blacklist\BlacklistContext; @@ -21,16 +19,16 @@ class UploadsRoutes implements IRouteHandler { public function registerRoutes(IRouter $router): void { if($this->isApiDomain) { - Route::handleAttributes($router, $this); + HandlerAttribute::register($router, $this); } else { $router->options('/', $this->getUpload(...)); - $router->get('/:filename', $this->getUpload(...)); + $router->get('/([A-Za-z0-9]+)', $this->getUpload(...)); } } - #[Route('OPTIONS', '/uploads/:filename')] - #[Route('GET', '/uploads/:filename')] - public function getUpload($response, $request, string $fileName) { + #[HttpOptions('/uploads/([A-Za-z0-9]+)(?:\.(t|json))?')] + #[HttpGet('/uploads/([A-Za-z0-9]+)(?:\.(t|json))?')] + public function getUpload($response, $request, string $fileId, string $fileExt = '') { if($this->isApiDomain) { if($request->hasHeader('Origin')) $response->setHeader('Access-Control-Allow-Credentials', 'true'); @@ -44,9 +42,6 @@ class UploadsRoutes implements IRouteHandler { if($request->getMethod() === 'OPTIONS') return 204; - $pathInfo = pathinfo($fileName); - $fileId = $pathInfo['filename']; - $fileExt = $pathInfo['extension'] ?? ''; $isData = $fileExt === ''; $isThumbnail = $fileExt === 't'; $isJson = $this->isApiDomain && $fileExt === 'json'; @@ -113,8 +108,8 @@ class UploadsRoutes implements IRouteHandler { $response->setFileName(addslashes($fileName)); } - #[Route('OPTIONS', '/uploads')] - #[Route('POST', '/uploads')] + #[HttpOptions('/uploads')] + #[HttpPost('/uploads')] public function postUpload($response, $request) { if($request->hasHeader('Origin')) $response->setHeader('Access-Control-Allow-Credentials', 'true'); @@ -192,7 +187,7 @@ class UploadsRoutes implements IRouteHandler { return $this->uploadsCtx->convertToClientJsonV1($uploadInfo); } - #[Route('DELETE', '/uploads/:fileid')] + #[HttpDelete('/uploads/([A-Za-z0-9]+)')] public function deleteUpload($response, $request, string $fileId) { if($request->hasHeader('Origin')) $response->setHeader('Access-Control-Allow-Credentials', 'true');