From 3fce5f2ce1a5566f66ed73272e9f47fb3d1d7cc3 Mon Sep 17 00:00:00 2001 From: mehmet-yoti Date: Tue, 18 Jun 2024 12:48:03 +0300 Subject: [PATCH] SDK-2265 removed profile attributes, updated namings, removed unnecessary comments --- examples/digitalidentity/.env.example | 3 +- examples/digitalidentity/README.md | 9 ++-- .../Http/Controllers/IdentityController.php | 42 ++++++------------- .../Http/Controllers/ReceiptController.php | 6 +-- examples/digitalidentity/config/yoti.php | 1 - .../resources/views/identity.blade.php | 16 +++---- examples/digitalidentity/routes/web.php | 1 + 7 files changed, 27 insertions(+), 51 deletions(-) diff --git a/examples/digitalidentity/.env.example b/examples/digitalidentity/.env.example index 059515cf..72022df2 100644 --- a/examples/digitalidentity/.env.example +++ b/examples/digitalidentity/.env.example @@ -1,14 +1,13 @@ # This file is a template for defining the environment variables # Set the application config values here -YOTI_SCENARIO_ID=xxxxxxxxxxxxxxxx YOTI_SDK_ID=xxxxxxxxxxxxxxxxxxxxx # Below is the private key (in .pem format) associated with the Yoti Application you created on Yoti Hub YOTI_KEY_FILE_PATH=./keys/php-sdk-access-security.pem # Laravel config: -APP_NAME=yoti.sdk.profile.demo +APP_NAME=yoti.sdk.digitalidentity.demo APP_ENV=local APP_KEY= APP_DEBUG=true diff --git a/examples/digitalidentity/README.md b/examples/digitalidentity/README.md index 162b83cb..8faa9b32 100644 --- a/examples/digitalidentity/README.md +++ b/examples/digitalidentity/README.md @@ -1,4 +1,4 @@ -# Profile Example +# Digital Identity Example ## Requirements @@ -8,11 +8,10 @@ This example requires [Docker](https://docs.docker.com/) * Create your application in the [Yoti Hub](https://hub.yoti.com) (this requires having a Yoti account) * Set the application domain of your app to `localhost:4002` - * Set the scenario callback URL to `/digitalidentity` -* Do the steps below inside the [examples/digitaledentity](./) folder +* Do the steps below inside the [examples/digitalidentity](./) folder * Put `your-application-pem-file.pem` file inside the [keys](keys) folder, as Docker requires the `.pem` file to reside within the same location where it's run from. * Copy `.env.example` to `.env` -* Open `.env` file and fill in the environment variables `YOTI_SCENARIO_ID`, `YOTI_SDK_ID` +* Open `.env` file and fill in the environment variable `YOTI_SDK_ID` * Set `YOTI_KEY_FILE_PATH` to `./keys/your-application-pem-file.pem` * Install dependencies `docker-compose up composer` * Run the `docker-compose up --build` command @@ -23,5 +22,3 @@ This example requires [Docker](https://docs.docker.com/) ## Digital Identity Example * Visit [/generate-share](https://localhost:4002/generate-share) - -> To see how to create a dynamic scenario, refer to the [Digital Identity controller](app/Http/Controllers/IdentityController.php) diff --git a/examples/digitalidentity/app/Http/Controllers/IdentityController.php b/examples/digitalidentity/app/Http/Controllers/IdentityController.php index 33a53d66..72ba9fc3 100644 --- a/examples/digitalidentity/app/Http/Controllers/IdentityController.php +++ b/examples/digitalidentity/app/Http/Controllers/IdentityController.php @@ -4,6 +4,7 @@ use Illuminate\Routing\Controller as BaseController; use Illuminate\Support\Facades\Log; +use mysql_xdevapi\Exception; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Yoti\DigitalIdentityClient; use Yoti\Identity\Policy\PolicyBuilder; @@ -12,7 +13,7 @@ class IdentityController extends BaseController { - public function show(DigitalIdentityClient $client) + public function generateSession(DigitalIdentityClient $client) { try { @@ -36,39 +37,20 @@ public function show(DigitalIdentityClient $client) ->withPolicy($policy) ->withRedirectUri($redirectUri) ->build(); - $session = $client->createShareSession($shareSessionRequest); - - $createdQrCode = $client->createShareQrCode($session->getId()); - - $fetchedQrCode = $client->fetchShareQrCode($createdQrCode->getId()); - - $sessionFetched = $client->fetchShareSession($session->getId()); - + return $session->getId(); + } + catch (\Throwable $e) { + Log::error($e->getTraceAsString()); + throw new BadRequestHttpException($e->getMessage()); + } + } + public function show(DigitalIdentityClient $client) + { + try { return view('identity', [ 'title' => 'Digital Identity Complete Example', - // Creating session - 'sessionId' => $session->getId(), - 'sessionStatus' => $session->getStatus(), - 'sessionExpiry' => $session->getExpiry(), - // Creating QR code - 'createdQrCodeId' => $createdQrCode->getId(), - 'createdQrCodeUri' => $createdQrCode->getUri(), - // Fetch QR code - 'fetchedQrCodeExpiry' => $fetchedQrCode->getExpiry(), - - 'fetchedQrCodeRedirectUri' => $fetchedQrCode->getRedirectUri(), - 'fetchedQrCodeSessionId' => $fetchedQrCode->getSession()->getId(), - 'fetchedQrCodeSessionStatus' => $fetchedQrCode->getSession()->getStatus(), - 'fetchedQrCodeSessionExpiry' => $fetchedQrCode->getSession()->getExpiry(), - // Fetch session - 'fetchedSessionId' => $sessionFetched->getId(), - 'fetchedSessionStatus' => $sessionFetched->getStatus(), - 'fetchedSessionExpiry' => $sessionFetched->getExpiry(), - 'fetchedSessionCreated' => $sessionFetched->getCreated(), - 'fetchedSessionUpdated' => $sessionFetched->getUpdated(), 'sdkId' => $client->id - ]); } catch (\Throwable $e) { Log::error($e->getTraceAsString()); diff --git a/examples/digitalidentity/app/Http/Controllers/ReceiptController.php b/examples/digitalidentity/app/Http/Controllers/ReceiptController.php index 50be0e79..39fe75a6 100644 --- a/examples/digitalidentity/app/Http/Controllers/ReceiptController.php +++ b/examples/digitalidentity/app/Http/Controllers/ReceiptController.php @@ -16,11 +16,9 @@ public function show(Request $request, DigitalIdentityClient $client, ?LoggerInt $logger = $logger ?? new Logger(); $logger->warning("Unknown Content Type parsing as a String"); - $activityDetails = $client->fetchShareReceipt($request->query('ReceiptID')); + $shareReceipt = $client->fetchShareReceipt($request->query('ReceiptID')); - // error_log("-------" . $activityDetails->getProfile()->getFullName()->getValue()); - - $profile = $activityDetails->getProfile(); + $profile = $shareReceipt->getProfile(); return view('receipt', [ 'fullName' => $profile->getFullName(), diff --git a/examples/digitalidentity/config/yoti.php b/examples/digitalidentity/config/yoti.php index 68e2c32b..d5f6e761 100644 --- a/examples/digitalidentity/config/yoti.php +++ b/examples/digitalidentity/config/yoti.php @@ -2,7 +2,6 @@ return [ 'client.sdk.id' => env('YOTI_SDK_ID'), - 'scenario.id' => env('YOTI_SCENARIO_ID'), 'pem.file.path' => (function($filePath) { return strpos($filePath, '/') === 0 ? $filePath : base_path($filePath); })(env('YOTI_KEY_FILE_PATH')), diff --git a/examples/digitalidentity/resources/views/identity.blade.php b/examples/digitalidentity/resources/views/identity.blade.php index 06917eed..de3cd057 100644 --- a/examples/digitalidentity/resources/views/identity.blade.php +++ b/examples/digitalidentity/resources/views/identity.blade.php @@ -10,9 +10,6 @@ -
- -
@@ -47,14 +44,19 @@
- - - diff --git a/examples/digitalidentity/routes/web.php b/examples/digitalidentity/routes/web.php index 43a83e6a..c592b91f 100644 --- a/examples/digitalidentity/routes/web.php +++ b/examples/digitalidentity/routes/web.php @@ -15,3 +15,4 @@ Route::get('/generate-share', 'IdentityController@show'); Route::get('/receipt-info', 'ReceiptController@show'); +Route::get('/generate-session', 'IdentityController@generateSession');