-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added-example-for-DBS-and-updated-failure-details
- Loading branch information
1 parent
a7473b9
commit 6ae1278
Showing
7 changed files
with
166 additions
and
4 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
examples/digitalidentity/app/Http/Controllers/DbsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters