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

Closed
netkas wants to merge 421 commits from master into dev
38 changed files with 129 additions and 129 deletions
Showing only changes of commit b8346e139c - Show all commits

View file

@ -2,7 +2,7 @@
namespace Socialbox\Abstracts;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\RpcRequest;
@ -15,7 +15,7 @@
* @param ClientRequest $request The full client request object, used to identify the client & it's requests
* @param RpcRequest $rpcRequest The selected RPC request for the method to handle
* @return SerializableInterface|null Returns RpcResponse/RpcError on success, null if the request is a notification
* @throws StandardException If a standard exception is thrown, it will be handled by the engine.
* @throws StandardRpcException If a standard exception is thrown, it will be handled by the engine.
*/
public static abstract function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface;
}

View file

@ -9,7 +9,7 @@
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -76,7 +76,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to add contact', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to add contact', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Return success

View file

@ -8,7 +8,7 @@
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -45,7 +45,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check if the contact exists', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check if the contact exists', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
}

View file

@ -8,7 +8,7 @@
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\MissingRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -53,7 +53,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to remove contact', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to remove contact', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Return success

View file

@ -6,7 +6,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -31,7 +31,7 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e);
}
try
@ -45,7 +45,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to get contact', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to get contact', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($contact->toStandard());

View file

@ -6,7 +6,7 @@
use Socialbox\Classes\Configuration;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -49,7 +49,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to get contacts', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to get contacts', StandardError::INTERNAL_SERVER_ERROR, $e);
}

View file

@ -6,7 +6,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -32,7 +32,7 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e);
}
if(!$rpcRequest->containsParameter('uuid'))
@ -46,7 +46,7 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e);
}
try
@ -63,7 +63,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Return success

View file

@ -7,7 +7,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\ContactRelationshipType;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\ContactManager;
use Socialbox\Objects\ClientRequest;
@ -32,7 +32,7 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Invalid peer address', StandardError::RPC_INVALID_ARGUMENTS, $e);
}
if(!$rpcRequest->containsParameter('relationship'))
@ -42,7 +42,7 @@
$relationship = ContactRelationshipType::tryFrom(strtoupper($rpcRequest->getParameter('relationship')));
if($relationship === null)
{
throw new StandardException('Invalid relationship type', StandardError::RPC_INVALID_ARGUMENTS);
throw new StandardRpcException('Invalid relationship type', StandardError::RPC_INVALID_ARGUMENTS);
}
try
@ -59,7 +59,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to update contact relationship', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Return success

View file

@ -6,7 +6,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\StandardMethods;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\RpcRequest;
@ -31,7 +31,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to retrieve allowed methods due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to retrieve allowed methods due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($allowedMethods);

View file

@ -7,7 +7,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\ReservedUsernames;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\PeerAddress;
@ -35,7 +35,7 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
}
// Check if host is making the request & the identifier is not empty
@ -52,7 +52,7 @@
}
catch(Exception $e)
{
throw new StandardException(sprintf('There was an error while trying to resolve the peer %s: %s', $peerAddress, $e->getMessage()), StandardError::RESOLUTION_FAILED, $e);
throw new StandardRpcException(sprintf('There was an error while trying to resolve the peer %s: %s', $peerAddress, $e->getMessage()), StandardError::RESOLUTION_FAILED, $e);
}
}
}

View file

@ -6,7 +6,7 @@
use InvalidArgumentException;
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\ClientRequest;
use Socialbox\Objects\PeerAddress;
@ -39,7 +39,7 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Invalid UUID', StandardError::RPC_INVALID_ARGUMENTS, $e);
}
// Parse the peer address
@ -49,20 +49,20 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException('Peer Address Error: ' . $e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
}
try
{
return $rpcRequest->produceResponse(Socialbox::resolvePeerSignature($peerAddress, $uuid->toRfc4122()));
}
catch(StandardException $e)
catch(StandardRpcException $e)
{
throw $e;
}
catch (Exception $e)
{
throw new StandardException('Failed to resolve peer signature', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to resolve peer signature', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
}

View file

@ -9,7 +9,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Managers\SessionManager;
@ -62,7 +62,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to retrieve current peer information', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to retrieve current peer information', StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -76,7 +76,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to add the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to add the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Update the session flow if necessary
@ -130,15 +130,15 @@
catch (DatabaseOperationException $e)
{
// Something is seriously wrong if we can't roll back the information field
throw new StandardException('Failed to rollback the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to rollback the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
}
if($e instanceof StandardException)
if($e instanceof StandardRpcException)
{
throw $e;
}
throw new StandardException('Failed to update the session flow', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to update the session flow', StandardError::INTERNAL_SERVER_ERROR, $e);
}

View file

@ -7,7 +7,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Classes\Configuration;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\SigningKeysManager;
use Socialbox\Objects\ClientRequest;
@ -54,7 +54,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to add the signing key', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to add the signing key', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($uuid);

View file

@ -7,7 +7,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Objects\ClientRequest;
@ -40,7 +40,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to check if the information field exists', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check if the information field exists', StandardError::INTERNAL_SERVER_ERROR, $e);
}
switch($fieldName)
@ -111,7 +111,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to delete the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to delete the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse(true);

View file

@ -8,7 +8,7 @@
use Socialbox\Classes\Cryptography;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\OneTimePasswordManager;
use Socialbox\Managers\PasswordManager;
@ -38,7 +38,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -47,7 +47,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Password verification is required to set an OTP if a password is set
@ -72,7 +72,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
@ -83,7 +83,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse(true);

View file

@ -8,7 +8,7 @@
use Socialbox\Classes\Cryptography;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\CryptographyException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PasswordManager;
use Socialbox\Objects\ClientRequest;
@ -67,7 +67,7 @@
}
catch (Exception $e)
{
throw new StandardException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Success

View file

@ -7,7 +7,7 @@
use ncc\ThirdParty\Symfony\Uid\Uuid;
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\SigningKeysManager;
use Socialbox\Objects\ClientRequest;
@ -40,7 +40,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to delete the signing key', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to delete the signing key', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse(true);

View file

@ -6,7 +6,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Objects\ClientRequest;
@ -35,7 +35,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e);
}
if($fieldRecord === null)

View file

@ -5,7 +5,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Objects\ClientRequest;
@ -24,7 +24,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse(array_map(fn($result) => $result->toInformationFieldState(), $fieldRecords));

View file

@ -5,7 +5,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\SigningKeysManager;
use Socialbox\Objects\ClientRequest;
@ -29,7 +29,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e);
}
if($key === null)

View file

@ -5,7 +5,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\SigningKeysManager;
use Socialbox\Objects\ClientRequest;
@ -24,7 +24,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to get the signing keys', StandardError::INTERNAL_SERVER_ERROR, $e);
}
if(empty($keys))

View file

@ -8,7 +8,7 @@
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\OneTimePasswordManager;
use Socialbox\Managers\PasswordManager;
@ -34,7 +34,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check One Time Password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
if($peer->isEnabled())
@ -46,7 +46,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check password usage due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
else
@ -76,7 +76,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
@ -90,7 +90,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($totpUri);

View file

@ -8,7 +8,7 @@
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PasswordManager;
use Socialbox\Managers\SessionManager;
@ -41,7 +41,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -54,7 +54,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse(true);

View file

@ -6,7 +6,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Objects\ClientRequest;
@ -53,7 +53,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
}

View file

@ -7,7 +7,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PeerInformationManager;
use Socialbox\Objects\ClientRequest;
@ -55,7 +55,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to update the information field', StandardError::INTERNAL_SERVER_ERROR, $e);
}

View file

@ -7,7 +7,7 @@
use Socialbox\Classes\Cryptography;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PasswordManager;
use Socialbox\Objects\ClientRequest;
@ -49,7 +49,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to check password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -61,7 +61,7 @@
}
catch (Exception $e)
{
throw new StandardException('Failed to verify existing password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to verify existing password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -71,7 +71,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to set password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse(true);

View file

@ -6,7 +6,7 @@
use Socialbox\Abstracts\Method;
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\SessionManager;
use Socialbox\Objects\ClientRequest;
@ -35,7 +35,7 @@
}
catch(Exception $e)
{
throw new StandardException('An error occurred while authenticating the peer', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('An error occurred while authenticating the peer', StandardError::INTERNAL_SERVER_ERROR, $e);
}

View file

@ -6,7 +6,7 @@
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\CaptchaManager;
use Socialbox\Managers\SessionManager;
@ -37,7 +37,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException("There was an unexpected error while trying to get the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException("There was an unexpected error while trying to get the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -51,7 +51,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException("There was an unexpected error while trying to answer the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($result);

View file

@ -7,7 +7,7 @@
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\CaptchaManager;
use Socialbox\Objects\ClientRequest;
@ -53,7 +53,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException("There was an unexpected error while trying create the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException("There was an unexpected error while trying create the captcha", StandardError::INTERNAL_SERVER_ERROR, $e);
}
// Build the captcha

View file

@ -8,7 +8,7 @@
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\CryptographyException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\OneTimePasswordManager;
use Socialbox\Managers\SessionManager;
@ -55,7 +55,7 @@
}
catch (Exception $e)
{
throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($result);

View file

@ -8,7 +8,7 @@
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\CryptographyException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\PasswordManager;
use Socialbox\Managers\SessionManager;
@ -54,7 +54,7 @@
}
catch (Exception $e)
{
throw new StandardException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to verify password due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $rpcRequest->produceResponse($result);

View file

@ -40,7 +40,7 @@
use Socialbox\Classes\StandardMethods\Verification\VerificationPasswordAuthentication;
use Socialbox\Enums\Flags\SessionFlags;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Managers\OneTimePasswordManager;
use Socialbox\Managers\PasswordManager;
@ -145,7 +145,7 @@
* @param ClientRequest $request The client request object containing necessary data for execution.
* @param RpcRequest $rpcRequest The RPC request object providing additional parameters for execution.
* @return SerializableInterface|null The result of the operation as a serializable interface or null if no operation matches.
* @throws StandardException If an error occurs during execution
* @throws StandardRpcException If an error occurs during execution
*/
public function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
{
@ -206,7 +206,7 @@
* @param ClientRequest $clientRequest The client request instance to check access against.
* @return void
* @throws DatabaseOperationException If an error occurs while checking the database for session information.
* @throws StandardException If the method is not allowed for the given client request.
* @throws StandardRpcException If the method is not allowed for the given client request.
*/
public function checkAccess(ClientRequest $clientRequest): void
{
@ -215,7 +215,7 @@
return;
}
throw new StandardException(StandardError::METHOD_NOT_ALLOWED->getMessage(), StandardError::METHOD_NOT_ALLOWED);
throw new StandardRpcException(StandardError::METHOD_NOT_ALLOWED->getMessage(), StandardError::METHOD_NOT_ALLOWED);
}
/**

View file

@ -4,7 +4,7 @@
use Socialbox\Enums\StandardError;
class InvalidRpcArgumentException extends StandardException
class InvalidRpcArgumentException extends StandardRpcException
{
/**
* Thrown when a required parameter is missing

View file

@ -4,7 +4,7 @@
use Socialbox\Enums\StandardError;
class MissingRpcArgumentException extends StandardException
class MissingRpcArgumentException extends StandardRpcException
{
/**
* Thrown when a required parameter is missing

View file

@ -10,7 +10,7 @@
use Socialbox\Objects\RpcRequest;
use Throwable;
class StandardException extends Exception
class StandardRpcException extends Exception
{
/**
* Thrown as a standard error, with a message and a code

View file

@ -15,7 +15,7 @@
use Socialbox\Enums\SessionState;
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\SessionRecord;
use Socialbox\Objects\KeyPair;
@ -181,7 +181,7 @@
* @param string $uuid The unique identifier of the session.
* @return SessionRecord The session record corresponding to the given UUID.
* @throws DatabaseOperationException If the session record cannot be found or if there is an error during retrieval.
* @throws StandardException
* @throws StandardRpcException
*/
public static function getSession(string $uuid): SessionRecord
{
@ -196,7 +196,7 @@
if ($data === false)
{
throw new StandardException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND);
throw new StandardRpcException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND);
}
// Convert the timestamp fields to DateTime objects
@ -308,7 +308,7 @@
*
* @param string $uuid The UUID of the session to retrieve flags for.
* @return SessionFlags[] An array of flags associated with the specified session.
* @throws StandardException If the specified session does not exist.
* @throws StandardRpcException If the specified session does not exist.
* @throws DatabaseOperationException If there
*/
private static function getFlags(string $uuid): array
@ -324,7 +324,7 @@
if ($data === false)
{
throw new StandardException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND);
throw new StandardRpcException(sprintf("The requested session '%s' does not exist", $uuid), StandardError::SESSION_NOT_FOUND);
}
return SessionFlags::fromString($data['flags']);
@ -341,7 +341,7 @@
* @param string $uuid The unique identifier of the session to which the flags will be added.
* @param array $flags The flags to add to the session.
* @return void
* @throws DatabaseOperationException|StandardException If there is an error while updating the session in the database.
* @throws DatabaseOperationException|StandardRpcException If there is an error while updating the session in the database.
*/
public static function addFlags(string $uuid, array $flags): void
{
@ -372,7 +372,7 @@
* @param string $uuid The UUID of the session from which the flags will be removed.
* @param SessionFlags[] $flags An array of flags to be removed from the session.
* @return void
* @throws DatabaseOperationException|StandardException If there is an error while updating the session in the database.
* @throws DatabaseOperationException|StandardRpcException If there is an error while updating the session in the database.
*/
public static function removeFlags(string $uuid, array $flags): void
{
@ -429,7 +429,7 @@
* @param array $flagsToRemove An array of flags to remove from the session if it is marked as complete.
* @return void
* @throws DatabaseOperationException If there is an error while updating the session in the database.
* @throws StandardException If the session record cannot be found or if there is an error during retrieval.
* @throws StandardRpcException If the session record cannot be found or if there is an error during retrieval.
*/
public static function updateFlow(SessionRecord $session, array $flagsToRemove=[]): void
{

View file

@ -6,7 +6,7 @@
use Socialbox\Classes\Logger;
use Socialbox\Enums\StandardError;
use Socialbox\Enums\StandardMethods;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Interfaces\SerializableInterface;
class RpcRequest implements SerializableInterface
@ -162,10 +162,10 @@
}
/**
* @param StandardException $e
* @param StandardRpcException $e
* @return RpcError|null
*/
public function handleStandardException(StandardException $e): ?RpcError
public function handleStandardException(StandardRpcException $e): ?RpcError
{
return $this->produceError($e->getStandardError(), $e->getMessage());
}

View file

@ -26,7 +26,7 @@
use Socialbox\Exceptions\RequestException;
use Socialbox\Exceptions\ResolutionException;
use Socialbox\Exceptions\RpcException;
use Socialbox\Exceptions\Standard\StandardException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Managers\ContactManager;
use Socialbox\Managers\ExternalSessionManager;
use Socialbox\Managers\PeerInformationManager;
@ -567,7 +567,7 @@
{
$method->checkAccess($clientRequest);
}
catch (StandardException $e)
catch (StandardRpcException $e)
{
$response = $e->produceError($rpcRequest);
$results[] = $response->toArray();
@ -587,7 +587,7 @@
$response = $method->execute($clientRequest, $rpcRequest);
Logger::getLogger()->debug(sprintf('%s method executed successfully', $rpcRequest->getMethod()));
}
catch(StandardException $e)
catch(StandardRpcException $e)
{
Logger::getLogger()->error('An error occurred while processing the RPC request', $e);
$response = $e->produceError($rpcRequest);
@ -755,7 +755,7 @@
* @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved.
* @param string $signatureUuid The UUID of the signature key to be resolved.
* @return SigningKey The resolved signing key for the peer.
* @throws StandardException If there was an error while resolving the peer signature key.
* @throws StandardRpcException If there was an error while resolving the peer signature key.
*/
public static function resolvePeerSignature(PeerAddress|string $peerAddress, string $signatureUuid): SigningKey
{
@ -768,14 +768,14 @@
}
catch(InvalidArgumentException $e)
{
throw new StandardException($e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
throw new StandardRpcException($e->getMessage(), StandardError::RPC_INVALID_ARGUMENTS, $e);
}
}
// Prevent resolutions against any host
if($peerAddress->getUsername() == ReservedUsernames::HOST)
{
throw new StandardException('Cannot resolve signature for a host peer', StandardError::FORBIDDEN);
throw new StandardRpcException('Cannot resolve signature for a host peer', StandardError::FORBIDDEN);
}
// If the peer is registered within this server
@ -788,22 +788,22 @@
if($peer === null || !$peer?->isEnabled())
{
// Fail if the peer is not found or enabled
throw new StandardException(sprintf('The peer %s does not exist', $peerAddress), StandardError::PEER_NOT_FOUND);
throw new StandardRpcException(sprintf('The peer %s does not exist', $peerAddress), StandardError::PEER_NOT_FOUND);
}
$signingKey = SigningKeysManager::getSigningKey($peer->getUuid(), $signatureUuid);
if($signingKey === null)
{
throw new StandardException(sprintf('The requested signing key %s was not found', $signatureUuid), StandardError::NOT_FOUND);
throw new StandardRpcException(sprintf('The requested signing key %s was not found', $signatureUuid), StandardError::NOT_FOUND);
}
}
catch(StandardException $e)
catch(StandardRpcException $e)
{
throw $e;
}
catch(Exception $e)
{
throw new StandardException('There was an error while trying to resolve the signature key for the peer locally', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('There was an error while trying to resolve the signature key for the peer locally', StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $signingKey->toStandard();
@ -816,7 +816,7 @@
}
catch(Exception $e)
{
throw new StandardException(sprintf('There was an error while trying to communicate with %s', $peerAddress->getDomain()), StandardError::RESOLUTION_FAILED, $e);
throw new StandardRpcException(sprintf('There was an error while trying to communicate with %s', $peerAddress->getDomain()), StandardError::RESOLUTION_FAILED, $e);
}
try
@ -826,7 +826,7 @@
catch(RpcException $e)
{
// Reflect the server error to the client
throw new StandardException($e->getMessage(), StandardError::tryFrom((int)$e->getCode()) ?? StandardError::UNKNOWN, $e);
throw new StandardRpcException($e->getMessage(), StandardError::tryFrom((int)$e->getCode()) ?? StandardError::UNKNOWN, $e);
}
}
@ -836,7 +836,7 @@
* @param PeerAddress|string $peerAddress The external peer address or string identifier to be resolved.
* @param PeerAddress|string|null $identifiedAs Optional. The peer address or string identifier by which the caller is identified
* @return Peer The resolved external peer after synchronization.
* @throws StandardException Thrown if there was an error with the resolution process
* @throws StandardRpcException Thrown if there was an error with the resolution process
*/
public static function resolvePeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer
{
@ -870,7 +870,7 @@
* @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved.
* @param PeerAddress|string|null $identifiedAs Optional. The peer address or string identifier by which the caller is identified
* @return Peer The resolved peer after synchronization.
* @throws StandardException Thrown if there was an error with the resolution process
* @throws StandardRpcException Thrown if there was an error with the resolution process
*/
private static function resolveExternalPeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer
{
@ -891,7 +891,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
}
if($existingPeer === null)
@ -904,7 +904,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e);
throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e);
}
try
@ -913,7 +913,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $peer;
@ -928,7 +928,7 @@
}
catch(Exception $e)
{
throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e);
throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::RESOLUTION_FAILED, $e);
}
try
@ -937,7 +937,7 @@
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to synchronize the external peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
}
return $peer;
@ -953,7 +953,7 @@
* @param PeerAddress|string $peerAddress The peer address or string identifier to be resolved.
* @param PeerAddress|string|null $identifiedAs Optional. The peer address or string identifier by which the caller is identified
* @return Peer The resolved peer after synchronization.
* @throws StandardException Thrown if there was an error with the resolution process
* @throws StandardRpcException Thrown if there was an error with the resolution process
*/
private static function resolveLocalPeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer
{
@ -974,12 +974,12 @@
if($peer === null)
{
throw new StandardException('The requested peer was not found', StandardError::PEER_NOT_FOUND);
throw new StandardRpcException('The requested peer was not found', StandardError::PEER_NOT_FOUND);
}
}
catch(DatabaseOperationException $e)
{
throw new StandardException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to resolve the peer: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
}
try
@ -989,7 +989,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
}
// If there's an identifier, we can resolve more information fields if the target peer has added the caller
@ -1002,7 +1002,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to resolve peer because there was an error while trying to retrieve contact information for the peer', StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to resolve peer because there was an error while trying to retrieve contact information for the peer', StandardError::INTERNAL_SERVER_ERROR, $e);
}
// If it is a contact, what sort of contact? retrieve depending on the contact type
@ -1023,7 +1023,7 @@
}
catch (DatabaseOperationException $e)
{
throw new StandardException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
throw new StandardRpcException('Failed to resolve peer information: ' . $e->getMessage(), StandardError::INTERNAL_SERVER_ERROR, $e);
}
}
}