-
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.
SDK-2420 Added support for advanced identity profile and examples
- Loading branch information
1 parent
399e849
commit 272c8cc
Showing
5 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
examples/digitalidentity/app/Http/Controllers/AdvancedIdentityController.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,70 @@ | ||
<?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 = ' | ||
{ | ||
"profiles": [ | ||
{ | ||
"trust_framework": "YOTI_GLOBAL", | ||
"schemes": [ | ||
{ | ||
"label": "identity-AL-L1", | ||
"type": "IDENTITY", | ||
"objective": "AL_L1" | ||
}, | ||
{ | ||
"label": "identity-AL-M1", | ||
"type": "IDENTITY", | ||
"objective": "AL_M1" | ||
} | ||
] | ||
} | ||
] | ||
}'; | ||
|
||
$policy = (new PolicyBuilder()) | ||
->withAdvancedIdentityProfileRequirements($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()); | ||
} | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
examples/digitalidentity/resources/views/advancedidentity.blade.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,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(Advanced)4 Share 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> |
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