Made message signing in Cryptography use SHA512 as the message content for... #1

Closed
netkas wants to merge 421 commits from master into dev
2 changed files with 18 additions and 8 deletions
Showing only changes of commit 466ebcd1a8 - Show all commits

View file

@ -2,18 +2,14 @@
namespace Socialbox\Classes\StandardMethods\Core;
use InvalidArgumentException;
use Socialbox\Abstracts\Method;
use Socialbox\Enums\ReservedUsernames;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\PeerAddress;
use Socialbox\Objects\RpcRequest;
use Socialbox\Socialbox;
class GetSelf extends Method
{
@ -23,6 +19,14 @@
*/
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
{
try
{
$selfPeer = $request->getPeer();
return $rpcRequest->produceResponse($selfPeer->toStandardPeer(PeerInformationManager::getFields($selfPeer)));
}
catch (DatabaseOperationException $e)
{
throw new StandardRpcException('Unable to resolve self peer', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
}

View file

@ -4,6 +4,7 @@
use InvalidArgumentException;
use Socialbox\Classes\Logger;
use Socialbox\Classes\Utilities;
use Socialbox\Enums\StandardError;
use Socialbox\Enums\StandardMethods;
use Socialbox\Exceptions\Standard\StandardRpcException;
@ -19,16 +20,21 @@
* Constructs the object from an array of data.
*
* @param string|StandardMethods $method The method of the request.
* @param string|null $id The ID of the request.
* @param string|null $id The ID of the request. If 'RANDOM' a random crc32 hash will be used.
* @param array|null $parameters The parameters of the request.
*/
public function __construct(string|StandardMethods $method, ?string $id, ?array $parameters=null)
public function __construct(string|StandardMethods $method, ?string $id='RANDOM', ?array $parameters=null)
{
if($method instanceof StandardMethods)
{
$method = $method->value;
}
if($id === 'RANDOM')
{
$id = Utilities::randomCrc32();;
}
$this->method = $method;
$this->parameters = $parameters;
$this->id = $id;