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

Closed
netkas wants to merge 421 commits from master into dev
8 changed files with 99 additions and 110 deletions
Showing only changes of commit 7a39b0fd35 - Show all commits

View file

@ -10,21 +10,21 @@
use Socialbox\Enums\Status\CaptchaStatus;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Objects\Database\CaptchaRecord;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
class CaptchaManager
{
/**
* Creates a new captcha for the given peer UUID.
*
* @param string|PeerRecord $peer_uuid The UUID of the peer to create the captcha for.
* @param string|PeerDatabaseRecord $peer_uuid The UUID of the peer to create the captcha for.
* @return string The answer to the captcha.
* @throws DatabaseOperationException If the operation fails.
*/
public static function createCaptcha(string|PeerRecord $peer_uuid): string
public static function createCaptcha(string|PeerDatabaseRecord $peer_uuid): string
{
// If the peer_uuid is a RegisteredPeerRecord, get the UUID
if($peer_uuid instanceof PeerRecord)
if($peer_uuid instanceof PeerDatabaseRecord)
{
$peer_uuid = $peer_uuid->getUuid();
}
@ -73,14 +73,14 @@
/**
* Answers a captcha for the given peer UUID.
*
* @param string|PeerRecord $peer_uuid The UUID of the peer to answer the captcha for.
* @param string|PeerDatabaseRecord $peer_uuid The UUID of the peer to answer the captcha for.
* @param string $answer The answer to the captcha.
* @return bool True if the answer is correct, false otherwise.
* @throws DatabaseOperationException If the operation fails.
*/
public static function answerCaptcha(string|PeerRecord $peer_uuid, string $answer): bool
public static function answerCaptcha(string|PeerDatabaseRecord $peer_uuid, string $answer): bool
{
if($peer_uuid instanceof PeerRecord)
if($peer_uuid instanceof PeerDatabaseRecord)
{
$peer_uuid = $peer_uuid->getUuid();
}
@ -129,14 +129,14 @@
/**
* Retrieves the captcha record for the given peer UUID.
*
* @param string|PeerRecord $peer_uuid The UUID of the peer to retrieve the captcha for.
* @param string|PeerDatabaseRecord $peer_uuid The UUID of the peer to retrieve the captcha for.
* @return CaptchaRecord|null The captcha record.
* @throws DatabaseOperationException If the operation fails.
*/
public static function getCaptcha(string|PeerRecord $peer_uuid): ?CaptchaRecord
public static function getCaptcha(string|PeerDatabaseRecord $peer_uuid): ?CaptchaRecord
{
// If the peer_uuid is a RegisteredPeerRecord, get the UUID
if($peer_uuid instanceof PeerRecord)
if($peer_uuid instanceof PeerDatabaseRecord)
{
$peer_uuid = $peer_uuid->getUuid();
}
@ -166,14 +166,14 @@
/**
* Checks if a captcha exists for the given peer UUID.
*
* @param string|PeerRecord $peer_uuid The UUID of the peer to check for a captcha.
* @param string|PeerDatabaseRecord $peer_uuid The UUID of the peer to check for a captcha.
* @return bool True if a captcha exists, false otherwise.
* @throws DatabaseOperationException If the operation fails.
*/
public static function captchaExists(string|PeerRecord $peer_uuid): bool
public static function captchaExists(string|PeerDatabaseRecord $peer_uuid): bool
{
// If the peer_uuid is a RegisteredPeerRecord, get the UUID
if($peer_uuid instanceof PeerRecord)
if($peer_uuid instanceof PeerDatabaseRecord)
{
$peer_uuid = $peer_uuid->getUuid();
}

View file

@ -10,20 +10,20 @@
use Socialbox\Classes\OtpCryptography;
use Socialbox\Exceptions\CryptographyException;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
class OneTimePasswordManager
{
/**
* Checks if a given peer uses OTP for authentication.
*
* @param string|PeerRecord $peerUuid Either a UUID as a string or a RegisteredPeerRecord object representing the peer.
* @param string|PeerDatabaseRecord $peerUuid Either a UUID as a string or a RegisteredPeerRecord object representing the peer.
* @return bool Returns true if the peer uses OTP, otherwise false.
* @throws DatabaseOperationException Thrown when a database error occurs.
*/
public static function usesOtp(string|PeerRecord $peerUuid): bool
public static function usesOtp(string|PeerDatabaseRecord $peerUuid): bool
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -45,12 +45,12 @@
/**
* Creates and stores a new OTP (One-Time Password) secret for the specified peer, and generates a key URI.
*
* @param string|PeerRecord $peer The unique identifier of the peer, either as a string UUID
* @param string|PeerDatabaseRecord $peer The unique identifier of the peer, either as a string UUID
* or an instance of RegisteredPeerRecord.
* @return string The generated OTP key URI that can be used for applications like authenticator apps.
* @throws DatabaseOperationException If there is an error during the database operation.
*/
public static function createOtp(string|PeerRecord $peer): string
public static function createOtp(string|PeerDatabaseRecord $peer): string
{
if(is_string($peer))
{
@ -84,16 +84,16 @@
/**
* Verifies the provided OTP (One-Time Password) against the stored secret associated with the specified peer.
*
* @param string|PeerRecord $peerUuid The unique identifier of the peer, either as a string UUID
* @param string|PeerDatabaseRecord $peerUuid The unique identifier of the peer, either as a string UUID
* or an instance of RegisteredPeerRecord.
* @param string $otp The OTP to be verified.
* @return bool Returns true if the OTP is valid; otherwise, false.
* @throws DatabaseOperationException If there is an error during the database operation.
* @throws CryptographyException If there is a failure in decrypting the stored OTP secret.
*/
public static function verifyOtp(string|PeerRecord $peerUuid, string $otp): bool
public static function verifyOtp(string|PeerDatabaseRecord $peerUuid, string $otp): bool
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -145,13 +145,13 @@
/**
* Deletes the OTP record associated with the specified peer.
*
* @param string|PeerRecord $peerUuid The peer's UUID or an instance of RegisteredPeerRecord whose OTP record needs to be deleted.
* @param string|PeerDatabaseRecord $peerUuid The peer's UUID or an instance of RegisteredPeerRecord whose OTP record needs to be deleted.
* @return void
* @throws DatabaseOperationException if the database operation fails.
*/
public static function deleteOtp(string|PeerRecord $peerUuid): void
public static function deleteOtp(string|PeerDatabaseRecord $peerUuid): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -171,12 +171,12 @@
/**
* Retrieves the last updated timestamp for the OTP record of the specified peer.
*
* @param string|PeerRecord $peerUuid The peer's UUID or an instance of RegisteredPeerRecord whose OTP record's last updated timestamp needs to be retrieved
* @param string|PeerDatabaseRecord $peerUuid The peer's UUID or an instance of RegisteredPeerRecord whose OTP record's last updated timestamp needs to be retrieved
* @return int The last updated timestamp of the OTP record, or 0 if no such record exists
*/
public static function getLastUpdated(string|PeerRecord $peerUuid): int
public static function getLastUpdated(string|PeerDatabaseRecord $peerUuid): int
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}

View file

@ -10,20 +10,20 @@
use Socialbox\Classes\Database;
use Socialbox\Exceptions\CryptographyException;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
class PasswordManager
{
/**
* Checks if the given peer UUID is associated with a password in the database.
*
* @param string|PeerRecord $peerUuid The UUID of the peer, or an instance of RegisteredPeerRecord from which the UUID will be retrieved.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer, or an instance of RegisteredPeerRecord from which the UUID will be retrieved.
* @return bool Returns true if the peer UUID is associated with a password, otherwise false.
* @throws DatabaseOperationException If an error occurs while querying the database.
*/
public static function usesPassword(string|PeerRecord $peerUuid): bool
public static function usesPassword(string|PeerDatabaseRecord $peerUuid): bool
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -45,15 +45,15 @@
/**
* Sets a secured password for the given peer UUID or registered peer record.
*
* @param string|PeerRecord $peerUuid The unique identifier or registered peer record of the user.
* @param string|PeerDatabaseRecord $peerUuid The unique identifier or registered peer record of the user.
* @param string $hash The plaintext password to be securely stored.
* @return void
* @throws DatabaseOperationException If an error occurs while storing the password in the database.
* @throws CryptographyException If an error occurs during password encryption or hashing.
*/
public static function setPassword(string|PeerRecord $peerUuid, string $hash): void
public static function setPassword(string|PeerDatabaseRecord $peerUuid, string $hash): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -84,15 +84,15 @@
/**
* Updates the secured password associated with the given peer UUID.
*
* @param string|PeerRecord $peerUuid The unique identifier or registered peer record of the user.
* @param string|PeerDatabaseRecord $peerUuid The unique identifier or registered peer record of the user.
* @param string $hash The new password to be stored securely.
* @return void
* @throws DatabaseOperationException If an error occurs while updating the password in the database.
* @throws CryptographyException If an error occurs while encrypting the password or validating the hash.
*/
public static function updatePassword(string|PeerRecord $peerUuid, string $hash): void
public static function updatePassword(string|PeerDatabaseRecord $peerUuid, string $hash): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -124,13 +124,13 @@
/**
* Deletes the stored password for a specific peer.
*
* @param string|PeerRecord $peerUuid The unique identifier of the peer, or an instance of RegisteredPeerRecord.
* @param string|PeerDatabaseRecord $peerUuid The unique identifier of the peer, or an instance of RegisteredPeerRecord.
* @return void
* @throws DatabaseOperationException If an error occurs during the database operation.
*/
public static function deletePassword(string|PeerRecord $peerUuid): void
public static function deletePassword(string|PeerDatabaseRecord $peerUuid): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -150,15 +150,15 @@
/**
* Verifies a given password against a stored password hash for a specific peer.
*
* @param string|PeerRecord $peerUuid The unique identifier of the peer, or an instance of RegisteredPeerRecord.
* @param string|PeerDatabaseRecord $peerUuid The unique identifier of the peer, or an instance of RegisteredPeerRecord.
* @param string $sha512 The SHA-512 hash of the password to be verified.
* @return bool Returns true if the password matches the stored hash; false otherwise.
* @throws CryptographyException If the password hash is invalid or an error occurs during the cryptographic operation.
* @throws DatabaseOperationException If an error occurs during the database operation.
*/
public static function verifyPassword(string|PeerRecord $peerUuid, string $sha512): bool
public static function verifyPassword(string|PeerDatabaseRecord $peerUuid, string $sha512): bool
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}

View file

@ -9,23 +9,23 @@
use Socialbox\Enums\Types\InformationFieldName;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Objects\Database\PeerInformationFieldRecord;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
class PeerInformationManager
{
/**
* Adds a property to a peer's information record.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to add the property to.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to add the property to.
* @param InformationFieldName $property The name of the property to add.
* @param string $value The value of the property to add.
* @param PrivacyState|null $privacyState The privacy state of the property to add.
* @return void
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function addField(string|PeerRecord $peerUuid, InformationFieldName $property, string $value, ?PrivacyState $privacyState=null): void
public static function addField(string|PeerDatabaseRecord $peerUuid, InformationFieldName $property, string $value, ?PrivacyState $privacyState=null): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -65,15 +65,15 @@
/**
* Updates a property for a peer's information record.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to update the property for.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to update the property for.
* @param InformationFieldName $property The name of the property to update.
* @param string $value The new value of the property.
* @return void
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function updateField(string|PeerRecord $peerUuid, InformationFieldName $property, string $value): void
public static function updateField(string|PeerDatabaseRecord $peerUuid, InformationFieldName $property, string $value): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -101,15 +101,15 @@
/**
* Updates the privacy state for a property in a peer's information record.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to update the privacy state for.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to update the privacy state for.
* @param InformationFieldName $property The name of the property to update the privacy state for.
* @param PrivacyState $privacyState The new privacy state of the property.
* @return void
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function updatePrivacyState(string|PeerRecord $peerUuid, InformationFieldName $property, PrivacyState $privacyState): void
public static function updatePrivacyState(string|PeerDatabaseRecord $peerUuid, InformationFieldName $property, PrivacyState $privacyState): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -138,14 +138,14 @@
/**
* Checks if a property exists for a peer.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to check for the property.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to check for the property.
* @param InformationFieldName $property The name of the property to check for.
* @return bool
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function fieldExists(string|PeerRecord $peerUuid, InformationFieldName $property): bool
public static function fieldExists(string|PeerDatabaseRecord $peerUuid, InformationFieldName $property): bool
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -169,14 +169,14 @@
/**
* Gets a property from a peer's information record.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to get the property from.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to get the property from.
* @param InformationFieldName $property The name of the property to get.
* @return PeerInformationFieldRecord|null The property record, or null if it does not exist.
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function getField(string|PeerRecord $peerUuid, InformationFieldName $property): ?PeerInformationFieldRecord
public static function getField(string|PeerDatabaseRecord $peerUuid, InformationFieldName $property): ?PeerInformationFieldRecord
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -206,13 +206,13 @@
/**
* Gets all properties from a peer's information record.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to get the properties from.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to get the properties from.
* @return PeerInformationFieldRecord[]
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function getFields(string|PeerRecord $peerUuid): array
public static function getFields(string|PeerDatabaseRecord $peerUuid): array
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -240,14 +240,14 @@
/**
* Gets all properties from a peer's information record that match the provided privacy filters.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to get the properties from.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to get the properties from.
* @param PrivacyState[] $privacyFilters The privacy filters to apply.
* @return PeerInformationFieldRecord[] The filtered properties.
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function getFilteredFields(string|PeerRecord $peerUuid, array $privacyFilters): array
public static function getFilteredFields(string|PeerDatabaseRecord $peerUuid, array $privacyFilters): array
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}
@ -281,14 +281,14 @@
/**
* Deletes a property from a peer's information record.
*
* @param string|PeerRecord $peerUuid The UUID of the peer to delete the property from.
* @param string|PeerDatabaseRecord $peerUuid The UUID of the peer to delete the property from.
* @param InformationFieldName $property The name of the property to delete.
* @return void
* @throws DatabaseOperationException Thrown if the operation fails.
*/
public static function deleteField(string|PeerRecord $peerUuid, InformationFieldName $property): void
public static function deleteField(string|PeerDatabaseRecord $peerUuid, InformationFieldName $property): void
{
if($peerUuid instanceof PeerRecord)
if($peerUuid instanceof PeerDatabaseRecord)
{
$peerUuid = $peerUuid->getUuid();
}

View file

@ -14,7 +14,7 @@
use Socialbox\Enums\PrivacyState;
use Socialbox\Enums\ReservedUsernames;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
use Socialbox\Objects\PeerAddress;
use Socialbox\Objects\Standard\Peer;
use Symfony\Component\Uid\Uuid;
@ -88,13 +88,13 @@
* Deletes a peer from the database based on the given UUID or RegisteredPeerRecord.
* WARNING: This operation is cascading and will delete all associated data.
*
* @param string|PeerRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer to be deleted.
* @param string|PeerDatabaseRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer to be deleted.
* @return void
* @throws DatabaseOperationException If the operation fails.
*/
public static function deletePeer(string|PeerRecord $uuid): void
public static function deletePeer(string|PeerDatabaseRecord $uuid): void
{
if($uuid instanceof PeerRecord)
if($uuid instanceof PeerDatabaseRecord)
{
$uuid = $uuid->getUuid();
}
@ -116,13 +116,13 @@
/**
* Retrieves a registered peer record based on the given unique identifier or RegisteredPeerRecord object.
*
* @param string|PeerRecord $uuid The unique identifier of the registered peer, or an instance of RegisteredPeerRecord.
* @return PeerRecord Returns a RegisteredPeerRecord object containing the peer's information.
* @param string|PeerDatabaseRecord $uuid The unique identifier of the registered peer, or an instance of RegisteredPeerRecord.
* @return PeerDatabaseRecord Returns a RegisteredPeerRecord object containing the peer's information.
* @throws DatabaseOperationException If there is an error during the database operation.
*/
public static function getPeer(string|PeerRecord $uuid): PeerRecord
public static function getPeer(string|PeerDatabaseRecord $uuid): PeerDatabaseRecord
{
if($uuid instanceof PeerRecord)
if($uuid instanceof PeerDatabaseRecord)
{
$uuid = $uuid->getUuid();
}
@ -142,7 +142,7 @@
throw new DatabaseOperationException(sprintf("The requested peer '%s' does not exist", $uuid));
}
return new PeerRecord($result);
return new PeerDatabaseRecord($result);
}
catch(Exception $e)
{
@ -154,10 +154,10 @@
* Retrieves a peer record by the given username.
*
* @param PeerAddress $address The address of the peer to be retrieved.
* @return PeerRecord|null The record of the peer associated with the given username.
* @return PeerDatabaseRecord|null The record of the peer associated with the given username.
* @throws DatabaseOperationException If there is an error while querying the database.
*/
public static function getPeerByAddress(PeerAddress $address): ?PeerRecord
public static function getPeerByAddress(PeerAddress $address): ?PeerDatabaseRecord
{
Logger::getLogger()->verbose(sprintf("Retrieving peer %s from the database", $address->getAddress()));
@ -184,7 +184,7 @@
return null;
}
return new PeerRecord($result);
return new PeerDatabaseRecord($result);
}
catch(Exception $e)
{
@ -291,13 +291,13 @@
/**
* Enables a peer identified by the given UUID or RegisteredPeerRecord.
*
* @param string|PeerRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer to be enabled.
* @param string|PeerDatabaseRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer to be enabled.
* @return void
* @throws DatabaseOperationException If there is an error while updating the database.
*/
public static function enablePeer(string|PeerRecord $uuid): void
public static function enablePeer(string|PeerDatabaseRecord $uuid): void
{
if($uuid instanceof PeerRecord)
if($uuid instanceof PeerDatabaseRecord)
{
$uuid = $uuid->getUuid();
}
@ -319,13 +319,13 @@
/**
* Disables the peer identified by the given UUID or RegisteredPeerRecord.
*
* @param string|PeerRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer.
* @param string|PeerDatabaseRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer.
* @return void
* @throws DatabaseOperationException If there is an error while updating the peer's status in the database.
*/
public static function disablePeer(string|PeerRecord $uuid): void
public static function disablePeer(string|PeerDatabaseRecord $uuid): void
{
if($uuid instanceof PeerRecord)
if($uuid instanceof PeerDatabaseRecord)
{
$uuid = $uuid->getUuid();
}
@ -347,14 +347,14 @@
/**
* Adds a specific flag to the peer identified by the given UUID or RegisteredPeerRecord.
*
* @param string|PeerRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer.
* @param string|PeerDatabaseRecord $uuid The UUID or RegisteredPeerRecord instance representing the peer.
* @param PeerFlags|array $flags The flag or array of flags to be added to the peer.
* @return void
* @throws DatabaseOperationException If there is an error while updating the database.
*/
public static function addFlag(string|PeerRecord $uuid, PeerFlags|array $flags): void
public static function addFlag(string|PeerDatabaseRecord $uuid, PeerFlags|array $flags): void
{
if($uuid instanceof PeerRecord)
if($uuid instanceof PeerDatabaseRecord)
{
$uuid = $uuid->getUuid();
}
@ -390,12 +390,12 @@
/**
* Removes a specific flag from the peer identified by the given UUID or RegisteredPeerRecord.
*
* @param string|PeerRecord $peer
* @param string|PeerDatabaseRecord $peer
* @param PeerFlags $flag The flag to be removed from the peer.
* @return void
* @throws DatabaseOperationException If there is an error while updating the database.
*/
public static function removeFlag(string|PeerRecord $peer, PeerFlags $flag): void
public static function removeFlag(string|PeerDatabaseRecord $peer, PeerFlags $flag): void
{
if(is_string($peer))
{

View file

@ -16,7 +16,7 @@
use Socialbox\Enums\StandardError;
use Socialbox\Exceptions\DatabaseOperationException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
use Socialbox\Objects\Database\SessionRecord;
use Socialbox\Objects\KeyPair;
use Symfony\Component\Uid\Uuid;
@ -26,7 +26,7 @@
/**
* Creates a new session for a given peer and client details, and stores it in the database.
*
* @param PeerRecord $peer The peer record for which the session is being created.
* @param PeerDatabaseRecord $peer The peer record for which the session is being created.
* @param string $clientName The name of the client application.
* @param string $clientVersion The version of the client application.
* @param string $clientPublicSigningKey The client's public signing key, which must be a valid Ed25519 key.
@ -36,7 +36,7 @@
* @throws InvalidArgumentException If the provided public signing key or encryption key is invalid.
* @throws DatabaseOperationException If there is an error during the session creation in the database.
*/
public static function createSession(PeerRecord $peer, string $clientName, string $clientVersion, string $clientPublicSigningKey, string $clientPublicEncryptionKey, KeyPair $serverEncryptionKeyPair): string
public static function createSession(PeerDatabaseRecord $peer, string $clientName, string $clientVersion, string $clientPublicSigningKey, string $clientPublicEncryptionKey, KeyPair $serverEncryptionKeyPair): string
{
if($clientPublicSigningKey === '' || Cryptography::validatePublicSigningKey($clientPublicSigningKey) === false)
{

View file

@ -11,7 +11,7 @@
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Managers\RegisteredPeerManager;
use Socialbox\Managers\SessionManager;
use Socialbox\Objects\Database\PeerRecord;
use Socialbox\Objects\Database\PeerDatabaseRecord;
use Socialbox\Objects\Database\SessionRecord;
class ClientRequest
@ -185,11 +185,11 @@
/**
* Retrieves the associated peer for the current session.
*
* @return PeerRecord|null Returns the associated RegisteredPeerRecord if available, or null if no session exists.
* @return PeerDatabaseRecord|null Returns the associated RegisteredPeerRecord if available, or null if no session exists.
* @throws DatabaseOperationException Thrown if an error occurs while retrieving the peer.
* @throws StandardRpcException Thrown if the session UUID is invalid.
*/
public function getPeer(): ?PeerRecord
public function getPeer(): ?PeerDatabaseRecord
{
$session = $this->getSession();

View file

@ -8,9 +8,8 @@
use Socialbox\Enums\Flags\PeerFlags;
use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\Standard\Peer;
use Socialbox\Objects\Standard\SelfUser;
class PeerRecord implements SerializableInterface
class PeerDatabaseRecord implements SerializableInterface
{
private string $uuid;
private string $username;
@ -195,16 +194,6 @@
return $this->username === 'host' && $this->server !== Configuration::getInstanceConfiguration()->getDomain();
}
/**
* Converts the current instance to a SelfUser object.
*
* @return SelfUser The SelfUser object.
*/
public function toSelfUser(): SelfUser
{
return new SelfUser($this);
}
/**
* Converts the current instance to a Peer object.
*