Skip to content

Commit d6e0021

Browse files
authored
Merge pull request #475 from getyoti/release/3.17.0
Release/3.17.0
2 parents 8330968 + 7984ba5 commit d6e0021

32 files changed

+658
-101
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using System.IO;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Logging;
5+
using Yoti.Auth;
6+
using Yoti.Auth.DigitalIdentity;
7+
using Yoti.Auth.DigitalIdentity.Policy;
8+
9+
namespace DigitalIdentityExample.Controllers
10+
{
11+
public class DbsController : Controller
12+
{
13+
private readonly string _clientSdkId;
14+
private readonly ILogger _logger;
15+
public DbsController(ILogger<DbsController> logger)
16+
{
17+
_logger = logger;
18+
19+
_clientSdkId = Environment.GetEnvironmentVariable("YOTI_CLIENT_SDK_ID");
20+
_logger.LogInformation(string.Format("Yoti Client SDK ID='{0}'", _clientSdkId));
21+
}
22+
23+
// GET: /generate-share
24+
[Route("dbs-share")]
25+
public IActionResult DigitalIdentity()
26+
{
27+
try
28+
{
29+
string yotiKeyFilePath = Environment.GetEnvironmentVariable("YOTI_KEY_FILE_PATH");
30+
_logger.LogInformation(
31+
string.Format(
32+
"yotiKeyFilePath='{0}'",
33+
yotiKeyFilePath));
34+
35+
StreamReader privateKeyStream = System.IO.File.OpenText(yotiKeyFilePath);
36+
37+
var yotiClient = new DigitalIdentityClient(_clientSdkId, privateKeyStream);
38+
39+
var givenNamesWantedAttribute = new WantedAttributeBuilder()
40+
.WithName("given_names")
41+
.WithOptional(false)
42+
.Build();
43+
44+
var notification = new NotificationBuilder()
45+
.WithUrl("https://example.com/webhook")
46+
.WithMethod("POST")
47+
.WithVerifyTls(true)
48+
.Build();
49+
50+
var policy = new PolicyBuilder()
51+
.WithIdentityProfileRequirements(new
52+
{
53+
trust_framework = "UK_TFIDA",
54+
scheme = new
55+
{
56+
type = "DBS",
57+
objective = "BASIC"
58+
}
59+
})
60+
.Build();
61+
62+
var sessionReq = new ShareSessionRequestBuilder()
63+
.WithPolicy(policy)
64+
.WithNotification(notification)
65+
.WithRedirectUri("https:/www.yoti.com")
66+
.WithSubject(new
67+
{
68+
subject_id = "some_subject_id_string"
69+
}).Build();
70+
71+
var SessionResult = yotiClient.CreateShareSession(sessionReq);
72+
73+
var sharedReceiptResponse = new SharedReceiptResponse();
74+
75+
ViewBag.YotiClientSdkId = _clientSdkId;
76+
ViewBag.sessionID = SessionResult.Id;
77+
78+
return View("Dbs", sharedReceiptResponse);
79+
}
80+
catch (Exception e)
81+
{
82+
_logger.LogError(
83+
exception: e,
84+
message: e.Message);
85+
86+
TempData["Error"] = e.Message;
87+
TempData["InnerException"] = e.InnerException?.Message;
88+
return RedirectToAction("Error", "Success");
89+
}
90+
}
91+
}
92+
}

src/Examples/DigitalIdentity/DigitalIdentity/Controllers/HomeController.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public IActionResult DigitalIdentity()
4141
.WithOptional(false)
4242
.Build();
4343

44+
var notification = new NotificationBuilder()
45+
.WithUrl("https://example.com/webhook")
46+
.WithMethod("POST")
47+
.WithVerifyTls(true)
48+
.Build();
49+
4450
var policy = new PolicyBuilder()
4551
.WithWantedAttribute(givenNamesWantedAttribute)
4652
.WithFullName()
@@ -54,16 +60,11 @@ public IActionResult DigitalIdentity()
5460
.WithDocumentImages()
5561
.Build();
5662

57-
var sessionReq = new ShareSessionRequestBuilder().WithPolicy(policy)
58-
.WithNotification(new Notification
59-
{
60-
Headers = { },
61-
Url = "https://example.com/webhook",
62-
Method = "POST",
63-
VerifyTls = true
64-
65-
})
66-
.WithRedirectUri("https:/www.yoti.com").WithSubject(new
63+
var sessionReq = new ShareSessionRequestBuilder()
64+
.WithPolicy(policy)
65+
.WithNotification(notification)
66+
.WithRedirectUri("https:/www.yoti.com")
67+
.WithSubject(new
6768
{
6869
subject_id = "some_subject_id_string"
6970
}).Build();

src/Examples/DigitalIdentity/DigitalIdentity/Controllers/SuccessController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public IActionResult ReceiptInfo(string ReceiptID)
5757
{
5858
displayAttributes.Base64Selfie = selfie.GetValue().GetBase64URI();
5959
}
60+
61+
displayAttributes.ErrorDetails = ReceiptResult.ErrorDetails;
62+
6063
ViewBag.YotiClientSdkId = _clientSdkId;
6164

6265
return View("SuccessResult", displayAttributes);

src/Examples/DigitalIdentity/DigitalIdentity/DigitalIdentityExample.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@
5252
<ItemGroup>
5353
<_ContentIncludedByDefault Remove="Pages\Success\SuccessResult.cshtml" />
5454
</ItemGroup>
55+
56+
5557
</Project>

src/Examples/DigitalIdentity/DigitalIdentity/Models/DisplayAttributes.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Yoti.Auth.Anchors;
3+
using Yoti.Auth.DigitalIdentity;
34

45
namespace DigitalIdentity.Models
56
{
@@ -8,6 +9,7 @@ public class DisplayAttributes
89
public List<DisplayAttribute> AttributeList { get; internal set; }
910
public string Base64Selfie { get; internal set; }
1011
public string FullName { get; internal set; }
12+
public ErrorReason ErrorDetails { get; internal set; }
1113

1214
internal DisplayAttributes()
1315
{
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
@{
2+
ViewData["Title"] = "Digital Identity - DBS";
3+
}
4+
@model Yoti.Auth.DigitalIdentity.SharedReceiptResponse
5+
6+
<!DOCTYPE html>
7+
<html class="yoti-html">
8+
9+
<head>
10+
<meta charset="utf-8" />
11+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
12+
<title>Yoti Digital Identity Client Example</title>
13+
<link rel="stylesheet" type="text/css" href="~/static/index.css" />
14+
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet" />
15+
</head>
16+
17+
<body class="yoti-body">
18+
19+
<main>
20+
<section class="yoti-top-section">
21+
<div class="yoti-logo-section">
22+
<img class="yoti-logo-image"
23+
src="~/static/assets/logo.png"
24+
srcset="~/static/assets/logo@2x.png 2x"
25+
alt="Yoti" />
26+
</div>
27+
28+
<h1 class="yoti-top-header">Digital Identity Share Example</h1>
29+
30+
<div class="yoti-sdk-integration-section">
31+
<div id="webshare-target"></div>
32+
</div>
33+
34+
</section>
35+
36+
<section class="yoti-sponsor-app-section">
37+
<h3 class="yoti-sponsor-app-header">The Yoti app is free to download and use:</h3>
38+
39+
<div class="yoti-store-buttons-section">
40+
<a href="https://itunes.apple.com/us/app/yoti/id983980808?ls=1&mt=8" class="yoti-app-button-link">
41+
<img src="~/static/assets/app-store-badge.png"
42+
srcset="~/static/assets/app-store-badge@2x.png 2x"
43+
alt="Download on the App Store" />
44+
</a>
45+
46+
<a href="https://play.google.com/store/apps/details?id=com.yoti.mobile.android.live" class="yoti-app-button-link">
47+
<img src="~/static/assets/google-play-badge.png"
48+
srcset="~/static/assets/google-play-badge@2x.png 2x"
49+
alt="get it on Google Play" />
50+
</a>
51+
</div>
52+
</section>
53+
</main>
54+
<script>async function onSessionIdResolver(id) {
55+
return '@ViewBag.sessionID'
56+
}
57+
58+
async function completionHandler(receivedReceiptId) {
59+
console.log('completion handler:', receivedReceiptId)
60+
const url = '/receipt-info?ReceiptID=' + encodeURIComponent(receivedReceiptId);
61+
62+
window.location.href = url;
63+
}
64+
65+
function onErrorListener(...data) {
66+
console.warn('onErrorListener:', ...data)
67+
}
68+
69+
async function onReadyToStart() {
70+
const { Yoti } = window
71+
await Yoti.createWebShare({
72+
name: 'Use Yoti',
73+
domId: 'webshare-target',
74+
sdkId: '@ViewBag.YotiClientSdkId',
75+
hooks: {
76+
sessionIdResolver: onSessionIdResolver,
77+
errorListener: onErrorListener,
78+
completionHandler,
79+
},
80+
flow: "REVEAL_MODAL"
81+
})
82+
}
83+
84+
async function onClientLoaded() {
85+
const { Yoti } = window
86+
await Yoti.ready()
87+
await onReadyToStart()
88+
}</script>
89+
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
90+
91+
</body>
92+
</html>

src/Examples/DigitalIdentity/DigitalIdentity/Views/Home/DigitalIdentity.cshtml

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,51 @@
77
<html class="yoti-html">
88

99
<head>
10-
<meta charset="utf-8" />
11-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
10+
<meta charset="utf-8"/>
11+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
1212
<title>Yoti Digital Identity Client Example</title>
13-
<link rel="stylesheet" type="text/css" href="~/static/index.css" />
14-
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet" />
13+
<link rel="stylesheet" type="text/css" href="~/static/index.css"/>
14+
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet"/>
1515
</head>
1616

1717
<body class="yoti-body">
1818

19-
<main>
20-
<section class="yoti-top-section">
21-
<div class="yoti-logo-section">
22-
<img class="yoti-logo-image"
23-
src="~/static/assets/logo.png"
24-
srcset="~/static/assets/logo@2x.png 2x"
25-
alt="Yoti" />
26-
</div>
27-
28-
<h1 class="yoti-top-header">Digital Identity Share Example</h1>
29-
30-
<div class="yoti-sdk-integration-section">
31-
<div id="webshare-target"></div>
32-
</div>
33-
34-
</section>
35-
36-
<section class="yoti-sponsor-app-section">
37-
<h3 class="yoti-sponsor-app-header">The Yoti app is free to download and use:</h3>
38-
39-
<div class="yoti-store-buttons-section">
40-
<a href="https://itunes.apple.com/us/app/yoti/id983980808?ls=1&mt=8" class="yoti-app-button-link">
41-
<img src="~/static/assets/app-store-badge.png"
42-
srcset="~/static/assets/app-store-badge@2x.png 2x"
43-
alt="Download on the App Store" />
44-
</a>
45-
46-
<a href="https://play.google.com/store/apps/details?id=com.yoti.mobile.android.live" class="yoti-app-button-link">
47-
<img src="~/static/assets/google-play-badge.png"
48-
srcset="~/static/assets/google-play-badge@2x.png 2x"
49-
alt="get it on Google Play" />
50-
</a>
51-
</div>
52-
</section>
53-
</main>
54-
<script>async function onSessionIdResolver(id) {
19+
<main>
20+
<section class="yoti-top-section">
21+
<div class="yoti-logo-section">
22+
<img class="yoti-logo-image"
23+
src="~/static/assets/logo.png"
24+
srcset="~/static/assets/logo@2x.png 2x"
25+
alt="Yoti"/>
26+
</div>
27+
28+
<h1 class="yoti-top-header">Digital Identity Share Example</h1>
29+
30+
<div class="yoti-sdk-integration-section">
31+
<div id="webshare-target"></div>
32+
</div>
33+
34+
</section>
35+
36+
<section class="yoti-sponsor-app-section">
37+
<h3 class="yoti-sponsor-app-header">The Yoti app is free to download and use:</h3>
38+
39+
<div class="yoti-store-buttons-section">
40+
<a href="https://itunes.apple.com/us/app/yoti/id983980808?ls=1&mt=8" class="yoti-app-button-link">
41+
<img src="~/static/assets/app-store-badge.png"
42+
srcset="~/static/assets/app-store-badge@2x.png 2x"
43+
alt="Download on the App Store"/>
44+
</a>
45+
46+
<a href="https://play.google.com/store/apps/details?id=com.yoti.mobile.android.live" class="yoti-app-button-link">
47+
<img src="~/static/assets/google-play-badge.png"
48+
srcset="~/static/assets/google-play-badge@2x.png 2x"
49+
alt="get it on Google Play"/>
50+
</a>
51+
</div>
52+
</section>
53+
</main>
54+
<script>async function onSessionIdResolver(id) {
5555
return '@ViewBag.sessionID'
5656
}
5757
@@ -86,7 +86,7 @@
8686
await Yoti.ready()
8787
await onReadyToStart()
8888
}</script>
89-
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
9089

90+
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
9191
</body>
9292
</html>

0 commit comments

Comments
 (0)