Major changes, revamp required

This commit is contained in:
netkas 2025-02-20 00:34:07 -05:00
parent 1f9890bba0
commit 29a3d42538
20 changed files with 523 additions and 662 deletions

View file

@ -16,8 +16,11 @@
use Socialbox\Classes\StandardMethods\Core\GetSessionState;
use Socialbox\Classes\StandardMethods\Core\Ping;
use Socialbox\Classes\StandardMethods\Core\ResolvePeer;
use Socialbox\Classes\StandardMethods\Core\ResolvePeerSignature;
use Socialbox\Classes\StandardMethods\Core\VerifyPeerSignature;
use Socialbox\Classes\StandardMethods\Core\ResolveSignature;
use Socialbox\Classes\StandardMethods\Core\VerifySignature;
use Socialbox\Classes\StandardMethods\Encryption\EncryptionAcceptChannel;
use Socialbox\Classes\StandardMethods\Encryption\EncryptionCloseChannel;
use Socialbox\Classes\StandardMethods\Encryption\EncryptionCreateChannel;
use Socialbox\Classes\StandardMethods\ServerDocuments\AcceptCommunityGuidelines;
use Socialbox\Classes\StandardMethods\ServerDocuments\AcceptPrivacyPolicy;
use Socialbox\Classes\StandardMethods\ServerDocuments\AcceptTermsOfService;
@ -127,14 +130,6 @@
// MISC
case GET_STATE = 'getState';
// End-to-End channels for communication purposes
case END_TO_END_CREATE_REQUEST = 'e2eCreateRequest';
case END_TO_END_GET_REQUESTS = 'e2eGetRequests';
case END_TO_END_ACCEPT_REQUEST = 'e2eAcceptRequest';
case END_TO_END_REJECT_REQUEST = 'e2eRejectRequest';
case END_TO_END_GET_CHANNELS = 'e2eGetChannels';
case END_TO_END_CLOSE_CHANNEL = 'e2eCloseChannel';
// Messaging methods
case MESSAGES_GET_INBOX = 'messagesGetInbox';
case MESSAGES_GET_UNTRUSTED = 'messagesGetUntrusted';
@ -189,8 +184,8 @@
self::GET_SESSION_STATE => GetSessionState::execute($request, $rpcRequest),
self::PING => Ping::execute($request, $rpcRequest),
self::RESOLVE_PEER => ResolvePeer::execute($request, $rpcRequest),
self::RESOLVE_PEER_SIGNATURE => ResolvePeerSignature::execute($request, $rpcRequest),
self::VERIFY_PEER_SIGNATURE => VerifyPeerSignature::execute($request, $rpcRequest),
self::RESOLVE_PEER_SIGNATURE => ResolveSignature::execute($request, $rpcRequest),
self::VERIFY_PEER_SIGNATURE => VerifySignature::execute($request, $rpcRequest),
// Server Document Methods
self::ACCEPT_PRIVACY_POLICY => AcceptPrivacyPolicy::execute($request, $rpcRequest),
@ -235,18 +230,13 @@
* Checks if the access method is allowed for the given client request.
*
* @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 StandardRpcException If the method is not allowed for the given client request.
* @return bool
*/
public function checkAccess(ClientRequest $clientRequest): void
public function checkAccess(ClientRequest $clientRequest): bool
{
if(in_array($this, self::getAllowedMethods($clientRequest)))
{
return;
}
throw new StandardRpcException(StandardError::METHOD_NOT_ALLOWED->getMessage(), StandardError::METHOD_NOT_ALLOWED);
return in_array($this, self::getAllowedMethods($clientRequest));
}
/**

View file

@ -5,32 +5,32 @@
enum SignatureVerificationStatus : string
{
/**
* The provided signature does not match the expected signature.
* Returned if the signature is invalid
*/
case INVALID = 'INVALID';
/**
* The provided signature was valid, but the public key used to verify the signature was not the expected public key.
* Returned if one or more of the parameters are invalid resulting in a failure to verify the signature
*/
case PUBLIC_KEY_MISMATCH = 'PUBLIC_KEY_MISMATCH';
case ERROR = 'ERROR';
/**
* The provided signature was valid, but the UUID used to verify the signature was not the expected UUID.
* Returned if the signing key is not found
*/
case UUID_MISMATCH = 'UUID_MISMATCH';
case NOT_FOUND = 'NOT_FOUND';
/**
* The provided signature was valid, but the signing key has expired.
* Returned if the signature has expired
*/
case EXPIRED = 'EXPIRED';
/**
* The provided signature was valid but unable to be verified against the peer's known public key.
* Returned if there was an error while trying to resolve the signature locally or externally
*/
case UNVERIFIED = 'UNVERIFIED';
case RESOLUTION_ERROR = 'RESOLUTION_ERROR';
/**
* The provided signature was valid and verified locally and against the peer's known public key successfully.
* Returned if the signature has been successfully verified
*/
case VERIFIED = 'VERIFIED';
}