Skip to content

Commit

Permalink
Added-example-for-DBS-and-updated-failure-details
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Jul 24, 2024
1 parent a7473b9 commit 6ae1278
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 4 deletions.
71 changes: 71 additions & 0 deletions examples/digitalidentity/app/Http/Controllers/DbsController.php
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 DbsController extends BaseController
{
public function generateSession(DigitalIdentityClient $client)
{
try {
$advancedIdentityProfileJson =
(object)[
"profiles" => [(object)[

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

"label" => "identity-AL-L1",
"type" => "DBS",
"objective"=> "BASIC"
],
[
"label" => "identity-AL-M1",
"type" => "DBS",
"objective" => "BASIC"
]
]
]
]
]
;

$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('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 @@ -84,6 +84,6 @@ function onErrorListener(...data) {
await Yoti.ready()
await onReadyToStart()
}</script>
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
<script src="https://www.public.stg1.dmz.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
</body>
</html>
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.public.stg1.dmz.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ function onErrorListener(...data) {
await Yoti.ready()
await onReadyToStart()
}</script>
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
<script src="https://www.public.stg1.dmz.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions examples/digitalidentity/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@
Route::get('/generate-session', 'IdentityController@generateSession');
Route::get('/generate-advanced-identity-share', 'AdvancedIdentityController@show');
Route::get('/generate-advanced-identity-session', 'AdvancedIdentityController@generateSession');
Route::get('/generate-dbs-share', 'DbsController@show');
Route::get('/generate-dbs-session', 'DbsController@generateSession');
2 changes: 1 addition & 1 deletion examples/profile/resources/views/advanced.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</section>
</main>

<script src="https://www.yoti.com/share/client/"></script>
<script src="https://www.public.stg1.dmz.yoti.com/share/client/"></script>
<script>
window.Yoti.Share.init(@json($buttonConfig, JSON_PRETTY_PRINT));
</script>
Expand Down
2 changes: 1 addition & 1 deletion examples/profile/resources/views/dbs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</section>
</main>

<script src="https://www.yoti.com/share/client/"></script>
<script src="https://www.public.stg1.dmz.yoti.com/share/client/"></script>
<script>
window.Yoti.Share.init(@json($buttonConfig, JSON_PRETTY_PRINT));
</script>
Expand Down

0 comments on commit 6ae1278

Please sign in to comment.