diff --git a/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionAcceptChannel.php b/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionAcceptChannel.php index 7972aed..f2043cc 100644 --- a/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionAcceptChannel.php +++ b/src/Socialbox/Classes/StandardMethods/EncryptionChannel/EncryptionAcceptChannel.php @@ -4,14 +4,11 @@ use Exception; use Socialbox\Abstracts\Method; - use Socialbox\Classes\Cryptography; use Socialbox\Classes\Logger; - use Socialbox\Classes\Validator; use Socialbox\Enums\StandardError; use Socialbox\Enums\Status\EncryptionChannelStatus; use Socialbox\Exceptions\DatabaseOperationException; use Socialbox\Exceptions\RpcException; - use Socialbox\Exceptions\Standard\InvalidRpcArgumentException; use Socialbox\Exceptions\Standard\MissingRpcArgumentException; use Socialbox\Exceptions\Standard\StandardRpcException; use Socialbox\Interfaces\SerializableInterface; @@ -55,19 +52,11 @@ { throw new MissingRpcArgumentException('channel_uuid'); } - elseif(!Validator::validateUuid($rpcRequest->getParameter('channel_uuid'))) - { - throw new InvalidRpcArgumentException('channel_uuid', 'The given channel uuid is not a valid UUID V4'); - } if(!$rpcRequest->containsParameter('public_encryption_key')) { throw new MissingRpcArgumentException('public_encryption_key'); } - elseif(!Cryptography::validatePublicEncryptionKey('public_encryption_key')) - { - throw new InvalidRpcArgumentException('public_encryption_key', 'The given public encryption key is invalid'); - } try { @@ -155,19 +144,11 @@ { throw new MissingRpcArgumentException('channel_uuid'); } - elseif(!Validator::validateUuid($rpcRequest->getParameter('channel_uuid'))) - { - throw new InvalidRpcArgumentException('channel_uuid', 'The given channel uuid is not a valid UUID V4'); - } if(!$rpcRequest->containsParameter('public_encryption_key')) { throw new MissingRpcArgumentException('public_encryption_key'); } - elseif(!Cryptography::validatePublicEncryptionKey('public_encryption_key')) - { - throw new InvalidRpcArgumentException('public_encryption_key', 'The given public encryption key is invalid'); - } try { diff --git a/src/Socialbox/SocialClient.php b/src/Socialbox/SocialClient.php index 8cbf420..dfed941 100644 --- a/src/Socialbox/SocialClient.php +++ b/src/Socialbox/SocialClient.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Socialbox\Classes\Cryptography; use Socialbox\Classes\RpcClient; + use Socialbox\Classes\Validator; use Socialbox\Enums\PrivacyState; use Socialbox\Enums\StandardMethods; use Socialbox\Enums\Status\SignatureVerificationStatus; @@ -537,6 +538,20 @@ { $identifiedAs = $identifiedAs->getAddress(); } + elseif(is_string($identifiedAs) && !Validator::validatePeerAddress($identifiedAs)) + { + throw new InvalidArgumentException('Invalid Peer Address'); + } + + if(!Validator::validateUuid($channelUuid)) + { + throw new InvalidArgumentException('Invalid Channel UUID V4'); + } + + if(!Cryptography::validatePublicEncryptionKey($publicEncryptionKey)) + { + throw new InvalidArgumentException('Invalid Public Encryption Key'); + } return $this->sendRequest( new RpcRequest(StandardMethods::ENCRYPTION_ACCEPT_CHANNEL, parameters: [