Skip to content

Commit

Permalink
Release/4.3.0 (#364)
Browse files Browse the repository at this point in the history
* SDK-2241 Create Session
* SDK-2244 Retrieve Session
* SDK-2250 Create QR Code
* SDK-2258 Retrieve QR Code
* SDK-2265 Retrieve Receipt 
* SDK-2377 added failure reasons to idv
* SDK-2357 added failure receipt error details
* Sdk 2420 php add support for advanced identity profiles to share v 2 and examples (#360)
* SDK-2371 added advanced identity profile to sharev1,example and updated tests
* Added-example-for-DBS-and-updated-failure-details
* Updated IDV Example Defaults
* Removed unneccessary used libraries
  • Loading branch information
mehmet-yoti authored Jul 31, 2024
1 parent c9a2b35 commit f752956
Show file tree
Hide file tree
Showing 187 changed files with 9,868 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ coverage
.scannerwork

.DS_Store
.php-cs-fixer.cache
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Add the Yoti SDK dependency:

```json
"require": {
"yoti/yoti-php-sdk" : "^4.1"
"yoti/yoti-php-sdk" : "^4.2.1"
}
```

Or run this Composer command
```console
$ composer require yoti/yoti-php-sdk "^4.1"
$ composer require yoti/yoti-php-sdk "^4.2.1"
```

## Setup
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yoti/yoti-php-sdk",
"description": "Yoti SDK for quickly integrating your PHP backend with Yoti",
"version": "4.2.2",
"version": "4.3.0",
"keywords": [
"yoti",
"sdk"
Expand Down Expand Up @@ -66,4 +66,4 @@
"phpstan/extension-installer": true
}
}
}
}
14 changes: 14 additions & 0 deletions examples/digitalidentity/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is a template for defining the environment variables
# Set the application config values here

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.digitalidentity.demo
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
16 changes: 16 additions & 0 deletions examples/digitalidentity/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

*.pem
keys/*.pem
sdk
24 changes: 24 additions & 0 deletions examples/digitalidentity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Digital Identity Example

## Requirements

This example requires [Docker](https://docs.docker.com/)

## Setup

* 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`
* 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 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
* Visit [https://localhost:4002](https://localhost:4002)
* Run the `docker-compose stop` command to stop the containers.

> To see how to retrieve activity details using the one time use token, refer to the [digitalidentity controller](app/Http/Controllers/IdentityController.php)
## Digital Identity Example
* Visit [/generate-share](https://localhost:4002/generate-share)
41 changes: 41 additions & 0 deletions examples/digitalidentity/app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
55 changes: 55 additions & 0 deletions examples/digitalidentity/app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Http\Controllers;

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;
use Yoti\Identity\ShareSessionRequestBuilder;
use Yoti\YotiClient;

class AdvancedIdentityController extends BaseController
{
public function generateSession(DigitalIdentityClient $client)
{
try {
$advancedIdentityProfileJson =
(object)[
"profiles" => [(object)[

"trust_framework" => "YOTI_GLOBAL",
"schemes" => [(object)[

"label" => "identity-AL-L1",
"type" => "IDENTITY",
"objective"=> "AL_L1"
],
[
"label" => "identity-AL-M1",
"type" => "IDENTITY",
"objective" => "AL_M1"
]
]
]
]
]
;

$policy = (new PolicyBuilder())
->withAdvancedIdentityProfileRequirements((object)$advancedIdentityProfileJson)
->build();

$redirectUri = 'https://host/redirect/';

$shareSessionRequest = (new ShareSessionRequestBuilder())
->withPolicy($policy)
->withRedirectUri($redirectUri)
->build();
$session = $client->createShareSession($shareSessionRequest);
return $session->getId();
}
catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
public function show(DigitalIdentityClient $client)
{
try {
return view('advancedidentity', [
'title' => 'Digital Identity(Advanced) Complete Example',
'sdkId' => $client->id
]);
} catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
}
53 changes: 53 additions & 0 deletions examples/digitalidentity/app/Http/Controllers/DbsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Yoti\DigitalIdentityClient;
use Yoti\Identity\Policy\PolicyBuilder;
use Yoti\Identity\ShareSessionRequestBuilder;

class DbsController extends BaseController
{
public function generateSession(DigitalIdentityClient $client)
{
try {
$policy = (new PolicyBuilder())
->withIdentityProfileRequirements((object)[
'trust_framework' => 'UK_TFIDA',
'scheme' => [
'type' => 'DBS',
'objective' => 'BASIC'
]
])
->build();

$redirectUri = 'https://host/redirect/';

$shareSessionRequest = (new ShareSessionRequestBuilder())
->withPolicy($policy)
->withRedirectUri($redirectUri)
->build();
$session = $client->createShareSession($shareSessionRequest);
return $session->getId();
}
catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
public function show(DigitalIdentityClient $client)
{
try {
return view('dbs', [
'title' => 'Digital Identity DBS Check Example',
'sdkId' => $client->id
]);
} catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Http\Controllers;

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;
use Yoti\Identity\ShareSessionRequestBuilder;
use Yoti\YotiClient;

class IdentityController extends BaseController
{
public function generateSession(DigitalIdentityClient $client)
{
try {

$policy = (new PolicyBuilder())
->withFamilyName()
->withGivenNames()
->withFullName()
->withDateOfBirth()
->withGender()
->withNationality()
->withPhoneNumber()
->withSelfie()
->withEmail()
->withDocumentDetails()
->withDocumentImages()
->build();

$redirectUri = 'https://host/redirect/';

$shareSessionRequest = (new ShareSessionRequestBuilder())
->withPolicy($policy)
->withRedirectUri($redirectUri)
->build();
$session = $client->createShareSession($shareSessionRequest);
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',
'sdkId' => $client->id
]);
} catch (\Throwable $e) {
Log::error($e->getTraceAsString());
throw new BadRequestHttpException($e->getMessage());
}
}
}
Loading

0 comments on commit f752956

Please sign in to comment.