Updated RPC library.

This commit is contained in:
flash 2024-11-13 23:30:34 +00:00
parent 23d47fa6d2
commit 8e006c7003
7 changed files with 59 additions and 53 deletions

View file

@ -1,7 +1,7 @@
{
"require": {
"flashwave/index": "^0.2410",
"flashwave/aiwass": "^1.1",
"flashii/rpcii": "^2.0",
"erusev/parsedown": "~1.6",
"chillerlan/php-qrcode": "^4.3",
"symfony/mailer": "^6.0",

72
composer.lock generated
View file

@ -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": "526f12235a073ac908e932627e1a16fa",
"content-hash": "33116c436dc775be3d0e0b1d33114224",
"packages": [
{
"name": "carbonphp/carbon-doctrine-types",
@ -417,12 +417,12 @@
"time": "2019-12-30T22:54:17+00:00"
},
{
"name": "flashwave/aiwass",
"version": "v1.1.0",
"name": "flashii/rpcii",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://patchii.net/flashii/aiwass.git",
"reference": "cf6653ed4676d549b543eeba2b9db517c1feb356"
"url": "https://patchii.net/flashii/rpcii-php.git",
"reference": "93ec139171d023f210f0b7464266b6fc42b4d838"
},
"require": {
"ext-msgpack": ">=2.2",
@ -430,13 +430,13 @@
"php": ">=8.3"
},
"require-dev": {
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^11.2"
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^11.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Aiwass\\": "src"
"RPCii\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -451,9 +451,9 @@
"role": "mom"
}
],
"description": "Shared HTTP RPC client/server library.",
"homepage": "https://railgun.sh/aiwass",
"time": "2024-10-05T00:04:26+00:00"
"description": "HTTP RPC client/server library.",
"homepage": "https://railgun.sh/rpcii",
"time": "2024-11-13T23:17:29+00:00"
},
{
"name": "flashwave/index",
@ -810,20 +810,20 @@
},
{
"name": "nesbot/carbon",
"version": "3.8.0",
"version": "3.8.2",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f"
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
"reference": "bbd3eef89af8ba66a3aa7952b5439168fbcc529f",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
"reference": "e1268cdbc486d97ce23fef2c666dc3c6b6de9947",
"shasum": ""
},
"require": {
"carbonphp/carbon-doctrine-types": "*",
"carbonphp/carbon-doctrine-types": "<100.0",
"ext-json": "*",
"php": "^8.1",
"psr/clock": "^1.0",
@ -912,7 +912,7 @@
"type": "tidelift"
}
],
"time": "2024-08-19T06:22:39+00:00"
"time": "2024-11-07T17:46:48+00:00"
},
{
"name": "psr/clock",
@ -1324,16 +1324,16 @@
},
{
"name": "sentry/sentry",
"version": "4.9.0",
"version": "4.10.0",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d"
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856",
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856",
"shasum": ""
},
"require": {
@ -1351,12 +1351,12 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"guzzlehttp/promises": "^1.0|^2.0",
"guzzlehttp/promises": "^2.0.3",
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
"monolog/monolog": "^1.6|^2.0|^3.0",
"phpbench/phpbench": "^1.0",
"phpstan/phpstan": "^1.3",
"phpunit/phpunit": "^8.5.14|^9.4",
"phpunit/phpunit": "^8.5|^9.6",
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
"vimeo/psalm": "^4.17"
},
@ -1397,7 +1397,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/4.9.0"
"source": "https://github.com/getsentry/sentry-php/tree/4.10.0"
},
"funding": [
{
@ -1409,7 +1409,7 @@
"type": "custom"
}
],
"time": "2024-08-08T14:40:50+00:00"
"time": "2024-11-06T07:44:19+00:00"
},
{
"name": "symfony/clock",
@ -2739,16 +2739,16 @@
},
{
"name": "twig/twig",
"version": "v3.14.0",
"version": "v3.14.2",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72"
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
"reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a",
"shasum": ""
},
"require": {
@ -2802,7 +2802,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.14.0"
"source": "https://github.com/twigphp/Twig/tree/v3.14.2"
},
"funding": [
{
@ -2814,22 +2814,22 @@
"type": "tidelift"
}
],
"time": "2024-09-09T17:55:12+00:00"
"time": "2024-11-07T12:36:22+00:00"
}
],
"packages-dev": [
{
"name": "phpstan/phpstan",
"version": "1.12.7",
"version": "1.12.10",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0"
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"reference": "dc2b9976bd8b0f84ec9b0e50cc35378551de7af0",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/fc463b5d0fe906dcf19689be692c65c50406a071",
"reference": "fc463b5d0fe906dcf19689be692c65c50406a071",
"shasum": ""
},
"require": {
@ -2874,7 +2874,7 @@
"type": "github"
}
],
"time": "2024-10-18T11:12:07+00:00"
"time": "2024-11-11T15:37:09+00:00"
}
],
"aliases": [],

View file

@ -22,7 +22,7 @@ Below are a number of links to source code repositories related to Flashii.net a
## First-Party Libraries
- [Index](https://patchii.net/flash/index): Base library used in almost any component of the website that uses PHP.
- [Aiwass](https://patchii.net/flashii/aiwass): Internal RPC extension, mainly used to supply data to the API gateway.
- [RPCii](https://patchii.net/flashii/rpcii): Internal RPC extension, mainly used to supply data to the API gateway.
## Historical
- [AJAX Chat (fork)](https://patchii.net/flashii/ajax-chat): Old chat software (2013-2015). Still kept on life support for the nostalgia.

View file

@ -3,10 +3,12 @@ namespace Misuzu\Auth;
use RuntimeException;
use Misuzu\Users\{UsersContext,UserInfo};
use Aiwass\Server\{RpcActionHandler,RpcProcedure};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction};
use Index\Config\Config;
final class AuthRpcActions extends RpcActionHandler {
final class AuthRpcHandler implements RpcHandler {
use RpcHandlerCommon;
public function __construct(
private Config $impersonateConfig,
private UsersContext $usersCtx,
@ -21,7 +23,7 @@ final class AuthRpcActions extends RpcActionHandler {
return in_array($targetId, $whitelist, true);
}
#[RpcProcedure('misuzu:auth:attemptMisuzuAuth')]
#[RpcAction('misuzu:auth:attemptMisuzuAuth')]
public function procAttemptMisuzuAuth(string $remoteAddr, string $token): array {
$tokenInfo = $this->authCtx->createAuthTokenPacker()->unpack($token);
if(!$tokenInfo->isEmpty())

View file

@ -5,12 +5,14 @@ use RuntimeException;
use Misuzu\CSRF;
use Misuzu\Auth\AuthContext;
use Misuzu\Users\{UsersContext,UserInfo};
use Aiwass\Server\{RpcActionHandler,RpcProcedure};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcAction};
use Index\Colour\Colour;
use Index\Config\Config;
use Index\Urls\UrlRegistry;
final class HanyuuRpcActions extends RpcActionHandler {
final class HanyuuRpcHandler implements RpcHandler {
use RpcHandlerCommon;
public function __construct(
private $getBaseUrl,
private Config $impersonateConfig,
@ -49,7 +51,7 @@ final class HanyuuRpcActions extends RpcActionHandler {
);
}
#[RpcProcedure('mszhau:authCheck')]
#[RpcAction('mszhau:authCheck')]
public function procAuthCheck(string $method, string $remoteAddr, string $token, string $avatars = '') {
if($method !== 'Misuzu')
return self::createErrorPayload('auth:check:method', 'Requested auth method is not supported.');

View file

@ -14,8 +14,8 @@ use Misuzu\News\News;
use Misuzu\Perms\Permissions;
use Misuzu\Profile\ProfileFields;
use Misuzu\Users\{UsersContext,UserInfo};
use Aiwass\HmacVerificationProvider;
use Aiwass\Server\RpcServer;
use RPCii\HmacVerificationProvider;
use RPCii\Server\HttpRpcServer;
use Index\Config\Config;
use Index\Db\DbConnection;
use Index\Db\Migration\{DbMigrationManager,DbMigrationRepo,FsDbMigrationRepo};
@ -281,30 +281,30 @@ class MisuzuContext {
$routingCtx->register(new LegacyRoutes($this->urls));
$rpcServer = new RpcServer;
$rpcServer = new HttpRpcServer;
$routingCtx->getRouter()->register($rpcServer->createRouteHandler(
new HmacVerificationProvider(fn() => $this->config->getString('aleister.secret'))
));
$rpcServer->register(new Auth\AuthRpcActions(
$rpcServer->register(new Auth\AuthRpcHandler(
$this->config->scopeTo('impersonate'),
$this->usersCtx,
$this->authCtx
));
$rpcServer->register(new Users\UsersRpcActions(
$rpcServer->register(new Users\UsersRpcHandler(
$this->siteInfo,
$this->urls,
$this->usersCtx
));
// This RPC server will eventually despawn when Hanyuu fully owns auth
$hanyuuRpcServer = new RpcServer;
$hanyuuRpcServer = new HttpRpcServer;
$routingCtx->getRouter()->scopeTo('/_hanyuu')->register($hanyuuRpcServer->createRouteHandler(
new HmacVerificationProvider(fn() => $this->config->getString('hanyuu.secret'))
));
$hanyuuRpcServer->register(new Hanyuu\HanyuuRpcActions(
$hanyuuRpcServer->register(new Hanyuu\HanyuuRpcHandler(
fn() => $this->config->getString('hanyuu.endpoint'),
$this->config->scopeTo('impersonate'),
$this->urls,

View file

@ -4,12 +4,14 @@ namespace Misuzu\Users;
use RuntimeException;
use Misuzu\SiteInfo;
use Misuzu\Users\Assets\UserAvatarAsset;
use Aiwass\Server\{RpcActionHandler,RpcQuery};
use RPCii\Server\{RpcHandler,RpcHandlerCommon,RpcQuery};
use Index\XArray;
use Index\Colour\{Colour,ColourRgb};
use Index\Urls\UrlRegistry;
final class UsersRpcActions extends RpcActionHandler {
final class UsersRpcHandler implements RpcHandler {
use RpcHandlerCommon;
public function __construct(
private SiteInfo $siteInfo,
private UrlRegistry $urls,