Skip to content

Commit

Permalink
SDK-2265 removed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed May 7, 2024
1 parent 41546f1 commit 42fe3d7
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.cache

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Identity/DigitalIdentityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ public function fetchShareReceipt(string $receiptId): Receipt
private function doFetchShareReceipt(string $receiptId): WrappedReceipt
{
$receiptIdUrl = strtr($receiptId, '+/', '-_');

$response = (new RequestBuilder($this->config))
->withBaseUrl($this->config->getApiUrl() ?? Constants::DIGITAL_IDENTITY_API_URL)
->withEndpoint(sprintf(self::IDENTITY_SESSION_RECEIPT_RETRIEVAL, $receiptIdUrl))
Expand Down
3 changes: 0 additions & 3 deletions src/Identity/ReceiptItemKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace Yoti\Identity;

use Yoti\Exception\EncryptedDataException;
use Yoti\Protobuf\Compubapi\EncryptedData;

class ReceiptItemKey
{
private string $id;
Expand Down
20 changes: 11 additions & 9 deletions src/Identity/ReceiptParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use Psr\Log\LoggerInterface;
use Yoti\Exception\EncryptedDataException;
use Yoti\Identity\Util\IdentityEncryptedData;
use Yoti\Profile\ApplicationProfile;
use Yoti\Profile\ExtraData;
use Yoti\Profile\UserProfile;
use Yoti\Profile\Util\Attribute\AttributeListConverter;
use Yoti\Profile\Util\ExtraData\ExtraDataConverter;
use Yoti\Identity\Util\IdentityEncryptedData;
use Yoti\Protobuf\Attrpubapi\AttributeList;
use Yoti\Util\Logger;
use Yoti\Util\PemFile;
Expand Down Expand Up @@ -95,17 +95,19 @@ public function createFailure(WrappedReceipt $wrappedReceipt): Receipt
private function decryptReceiptKey(string $wrappedKey, ReceiptItemKey $wrappedItemKey, PemFile $pemFile): string
{
// Convert 'iv' and 'value' from base64 to binary
$iv = base64_decode($wrappedItemKey->getIv(), true);
$encryptedItemKey = base64_decode($wrappedItemKey->getValue(), true);
$iv = (string)base64_decode($wrappedItemKey->getIv(), true);
$encryptedItemKey = (string)base64_decode($wrappedItemKey->getValue(), true);

// Decrypt the 'value' field (encrypted item key) using the private key
$unwrappedKey = '';
if (!openssl_private_decrypt(
$encryptedItemKey,
$unwrappedKey,
(string)$pemFile
)) {
throw new EncryptedDataException('Could not decrypt the item key');
if (
!openssl_private_decrypt(
$encryptedItemKey,
$unwrappedKey,
(string)$pemFile
)
) {
throw new EncryptedDataException('Could not decrypt the item key');
}

// Check that 'wrappedKey' is a base64-encoded string
Expand Down
4 changes: 2 additions & 2 deletions src/Identity/Util/IdentityEncryptedData.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class IdentityEncryptedData
{
/**
* @param string $data
* @param string $wrappedKey
* @param string $unwrappedKey
*
* @return string
*/
public static function decrypt(string $data, string $unwrappedKey): string
{
if ($data === false) {
if ($data === "") {
throw new EncryptedDataException('Could not decode data');
}

Expand Down
4 changes: 1 addition & 3 deletions src/Profile/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public function getActivityDetails(string $encryptedConnectToken): ActivityDetai
{
// Decrypt connect token
$token = $this->decryptConnectToken($encryptedConnectToken);
error_log($token);
// Request endpoint
$response = (new RequestBuilder($this->config))
->withBaseUrl($this->config->getApiUrl() ?? Constants::API_URL)
Expand All @@ -76,8 +75,7 @@ public function getActivityDetails(string $encryptedConnectToken): ActivityDetai
->execute();

$httpCode = $response->getStatusCode();
error_log("===>" . sprintf('/profile/%s', $token) . "<====");
//error_log((string)($response->getBody()));

if ($httpCode < 200 || $httpCode > 299) {
throw new ActivityDetailsException("Server responded with {$httpCode}", $response);
}
Expand Down

0 comments on commit 42fe3d7

Please sign in to comment.