Add VariableManager, RpcClient classes, and cache enhancements
This commit is contained in:
parent
38092a639e
commit
e55f4d57f9
27 changed files with 606 additions and 56 deletions
|
@ -2,7 +2,14 @@
|
|||
|
||||
namespace Socialbox\Objects;
|
||||
|
||||
use RuntimeException;
|
||||
use Socialbox\Classes\Cryptography;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Socialbox\Enums\StandardHeaders;
|
||||
use Socialbox\Exceptions\CryptographyException;
|
||||
use Socialbox\Exceptions\DatabaseOperationException;
|
||||
use Socialbox\Exceptions\StandardException;
|
||||
use Socialbox\Managers\SessionManager;
|
||||
|
||||
class ClientRequest
|
||||
{
|
||||
|
@ -95,15 +102,41 @@ class ClientRequest
|
|||
return $this->headers[StandardHeaders::SIGNATURE->value];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws DatabaseOperationException
|
||||
*/
|
||||
public function verifySignature(): bool
|
||||
{
|
||||
$signature = $this->getSignature();
|
||||
$sessionUuid = $this->getSessionUuid();
|
||||
|
||||
if($signature == null)
|
||||
if($signature == null || $sessionUuid == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$session = SessionManager::getSession($sessionUuid);
|
||||
}
|
||||
catch(StandardException $e)
|
||||
{
|
||||
if($e->getStandardError() == StandardError::SESSION_NOT_FOUND)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
throw new RuntimeException($e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Cryptography::verifyContent($this->getHash(), $signature, $session->getPublicKey());
|
||||
}
|
||||
catch(CryptographyException $e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
25
src/Socialbox/Objects/ResolvedServer.php
Normal file
25
src/Socialbox/Objects/ResolvedServer.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Objects;
|
||||
|
||||
class ResolvedServer
|
||||
{
|
||||
private string $endpoint;
|
||||
private string $publicKey;
|
||||
|
||||
public function __construct(string $endpoint, string $publicKey)
|
||||
{
|
||||
$this->endpoint = $endpoint;
|
||||
$this->publicKey = $publicKey;
|
||||
}
|
||||
|
||||
public function getEndpoint(): string
|
||||
{
|
||||
return $this->endpoint;
|
||||
}
|
||||
|
||||
public function getPublicKey(): string
|
||||
{
|
||||
return $this->publicKey;
|
||||
}
|
||||
}
|
|
@ -55,13 +55,6 @@ class RpcResponse implements SerializableInterface
|
|||
return $data->toArray();
|
||||
}
|
||||
|
||||
// If the data is an array, recursively apply this method to each element
|
||||
if (is_array($data))
|
||||
{
|
||||
return array_map([$this, 'convertToArray'], $data);
|
||||
}
|
||||
|
||||
// Otherwise, return the data as-is (e.g., for scalar values)
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue