Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #363

Open
wants to merge 5 commits into
base: old-release/4.3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3.0"
}
```

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

## Setup
Expand Down
6 changes: 3 additions & 3 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 All @@ -15,7 +15,7 @@
"phpseclib/phpseclib": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0",
"psr/http-message": "^2.0",
"guzzlehttp/psr7": "^2.4",
"ext-openssl": "*"
},
Expand Down Expand Up @@ -66,4 +66,4 @@
"phpstan/extension-installer": true
}
}
}
}
7 changes: 5 additions & 2 deletions examples/digitalidentity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ This example requires [Docker](https://docs.docker.com/)
* 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)

> To see how to retrieve a profile using share receipt, refer to the [receipt controller](app/Http/Controllers/ReceiptController.php)
## Digital Identity Example
* Visit [/generate-share](https://localhost:4002/generate-share)
## Digital Identity(Advanced) Share Example
* Visit [/generate-advanced-identity-share](https://localhost:4002/generate-advanced-identity-share)
* ## Digital Identity DBS Example
* Visit [/generate-dbs-share](https://localhost:4002/generate-dbs-share)
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

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
{
Expand Down
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
Expand Up @@ -4,12 +4,10 @@

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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace App\Http\Controllers;

use Yoti\DigitalIdentityClient;
use Yoti\YotiClient;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Yoti\Profile\Attribute;
use Yoti\Profile\UserProfile;
use Yoti\Util\Logger;

class ReceiptController extends BaseController
{
public function show(Request $request, DigitalIdentityClient $client, ?LoggerInterface $logger = null)
Expand All @@ -17,14 +17,25 @@ public function show(Request $request, DigitalIdentityClient $client, ?LoggerInt

$logger->warning("Unknown Content Type parsing as a String");
$shareReceipt = $client->fetchShareReceipt($request->query('ReceiptID'));

$profile = $shareReceipt->getProfile();

return view('receipt', [
'fullName' => $profile->getFullName(),
'selfie' => $profile->getSelfie(),
'profileAttributes' => $this->createAttributesDisplayList($profile),
]);
if ($shareReceipt->getError() != null)
{
error_log($shareReceipt->getErrorReason()->getRequirementNotMetDetails()->getDocumentCountryIsoCode());
return view('receipt', [
'fullName' => null,
'selfie' => null,
'profileAttributes' => null,
'error' => $shareReceipt->getErrorReason()
]);
}
else {
$profile = $shareReceipt->getProfile();
return view('receipt', [
'fullName' => $profile->getFullName(),
'selfie' => $profile->getSelfie(),
'profileAttributes' => $this->createAttributesDisplayList($profile),
'error' => null
]);
}
}

/**
Expand Down
89 changes: 89 additions & 0 deletions examples/digitalidentity/resources/views/dbs.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html class="yoti-html">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{{ $title }}</title>
<link rel="stylesheet" type="text/css" href="assets/css/index.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
</head>

<body class="yoti-body">
<main>
<section class="yoti-top-section">
<div class="yoti-logo-section">
<a href="https://www.yoti.com" target="_blank">
<img class="yoti-logo-image" src="assets/images/logo.png" srcset="assets/images/[email protected] 2x"
alt="Yoti"/>
</a>
</div>
<h1 class="yoti-top-header">Digital Identity DBS Ckeck Example</h1>

<div class="yoti-sdk-integration-section">
<div id="webshare-target"></div>
</div>

</section>

<section class="yoti-sponsor-app-section">
<h3 class="yoti-sponsor-app-header">The Yoti app is free to download and use:</h3>

<div class="yoti-store-buttons-section">
<a href="https://itunes.apple.com/us/app/yoti/id983980808?ls=1&mt=8" class="yoti-app-button-link">
<img src="assets/images/app-store-badge.png"
srcset="assets/images/[email protected] 2x"
alt="Download on the App Store" />
</a>

<a href="https://play.google.com/store/apps/details?id=com.yoti.mobile.android.live" class="yoti-app-button-link">
<img src="assets/images/google-play-badge.png"
srcset="assets/images/[email protected] 2x"
alt="get it on Google Play" />
</a>
</div>
</section>
</main>
<script>async function onSessionIdResolver() {
const response = await fetch('/generate-advanced-identity-session');
if (!response.ok) {
throw new Error('Response was not ok');
}
const result = await response.text();
console.log("session id %s", result);
return result;
}

async function completionHandler(receivedReceiptId) {
console.log('completion handler:', receivedReceiptId)
const url = '/receipt-info?ReceiptID=' + encodeURIComponent(receivedReceiptId);
window.location.href = url;
}

function onErrorListener(...data) {
console.warn('onErrorListener:', ...data)
}

async function onReadyToStart() {
const { Yoti } = window
await Yoti.createWebShare({
name: 'Use Yoti',
domId: 'webshare-target',
sdkId: '{{$sdkId}}',
hooks: {
sessionIdResolver: onSessionIdResolver,
errorListener: onErrorListener,
completionHandler,
},
flow: "REVEAL_MODAL"
})
}

async function onClientLoaded() {
const { Yoti } = window
await Yoti.ready()
await onReadyToStart()
}</script>
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
</body>
</html>
87 changes: 51 additions & 36 deletions examples/digitalidentity/resources/views/partial/report.blade.php
Original file line number Diff line number Diff line change
@@ -1,39 +1,54 @@
@foreach ($report as $key => $value)
<table>
<thead>
<tr>
<td>
<H2>{{ $key }}</H2>
</td>
</tr>
</thead>
<tbody>
@foreach ($value as $name => $result)
@if (is_array($result))
@foreach ($result as $data => $view)
@if (is_array($view))
@foreach ($view as $key2 => $value2)
@if (is_array($value2))
{{json_encode($value2)}}
@else
<tr>
<td><b>{{ $key2 }}</b><br>{{ $value2 }}</td>
</tr>
@endif
@endforeach
@else
<tr>
<td><b>{{ $data }}</b><br>{{ $view }}</td>
</tr>
@endif
@endforeach
@else
<tr>
@if (isset($key) && is_array($key))
@foreach ($report as $key => $value)
<table>
<thead>
<tr>
<td>
<H2>{{ $key }}</H2>
</td>
</tr>
</thead>
<tbody>
@foreach ($value as $name => $result)
@if (isset($result) && is_array($result))
@foreach ($result as $data => $view)
@if (is_array($view))
@foreach ($view as $key2 => $value2)
@if (is_array($value2))
{{json_encode($value2)}}
@else
<tr>
<td><b>{{ $key2 }}</b><br>{{ $value2 }}</td>
</tr>
@endif
@endforeach
@else
<tr>
<td><b>{{ $data }}</b><br>{{ $view }}</td>
</tr>
@endif
@endforeach
@else
<tr>
<td><b>{{ $name }}</b><br>{{ $result }}</td>
</tr>
@endif
@endforeach
</tr>
@endif
@endforeach

</tbody>
</table>
</tbody>
</table>
@endforeach
@else
<table>
@foreach ($report as $key => $value)
<tr>
<td>
{{ $key }}<br/>
<pre>
{!! json_encode($value, JSON_PRETTY_PRINT) !!}
</pre>
</td>
</tr>
@endforeach
</table>
@endif
Loading
Loading