Skip to content

Commit

Permalink
Merge branch 'development' into IN5631
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti authored Nov 10, 2023
2 parents 59a2e78 + b7ffc8d commit 3437a1d
Show file tree
Hide file tree
Showing 22 changed files with 1,091 additions and 56 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import "github.com/getyoti/yoti-go-sdk/v3"
```
or add the following line to your go.mod file (check https://github.com/getyoti/yoti-go-sdk/releases for the latest version)
```
require github.com/getyoti/yoti-go-sdk/v3 v3.10.0
require github.com/getyoti/yoti-go-sdk/v3 v3.11.0
```

## Setup
Expand Down
14 changes: 14 additions & 0 deletions _examples/idv/handlers.session.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ func showDBSPage(c *gin.Context) {
pageFromSessionSpec(c, sessionSpec)
}

func showAdvancedIdentityProfilePage(c *gin.Context) {
sessionSpec, err := buildAdvancedIdentityProfileSessionSpec()
if err != nil {
c.HTML(
http.StatusInternalServerError,
"error.html",
gin.H{
"ErrorTitle": "Error when building sessions spec",
"ErrorMessage": err.Error()})
return
}
pageFromSessionSpec(c, sessionSpec)
}

func pageFromSessionSpec(c *gin.Context, sessionSpec *create.SessionSpecification) {
err := initialiseDocScanClient()
if err != nil {
Expand Down
56 changes: 56 additions & 0 deletions _examples/idv/models.sessionspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,59 @@ func buildDBSSessionSpec() (sessionSpec *create.SessionSpecification, err error)

return sessionSpec, nil
}

func buildAdvancedIdentityProfileSessionSpec() (sessionSpec *create.SessionSpecification, err error) {
var sdkConfig *create.SDKConfig
sdkConfig, err = create.NewSdkConfigBuilder().
WithAllowsCameraAndUpload().
WithPrimaryColour("#2d9fff").
WithSecondaryColour("#FFFFFF").
WithFontColour("#FFFFFF").
WithLocale("en-GB").
WithPresetIssuingCountry("GBR").
WithSuccessUrl("https://localhost:8080/success").
WithErrorUrl("https://localhost:8080/error").
WithPrivacyPolicyUrl("https://localhost:8080/privacy-policy").
Build()
if err != nil {
return nil, err
}

advancedIdentityProfile := []byte(`{
"profiles": [
{
"trust_framework": "UK_TFIDA",
"schemes": [
{
"label": "LB912",
"type": "RTW"
}
]
},
{
"trust_framework": "YOTI_GLOBAL",
"schemes": [
{
"label": "LB321",
"type": "IDENTITY",
"objective": "AL_L1"
}
]
}
]
}`)

subject := []byte(`{
"subject_id": "unique-user-id-for-examples"
}`)

return create.NewSessionSpecificationBuilder().
WithClientSessionTokenTTL(6000).
WithResourcesTTL(900000).
WithUserTrackingID("some-tracking-id").
WithSDKConfig(sdkConfig).
WithAdvancedIdentityProfileRequirements(advancedIdentityProfile).
WithCreateIdentityProfilePreview(true).
WithSubject(subject).
Build()
}
1 change: 1 addition & 0 deletions _examples/idv/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ func initializeRoutes() {
// Handle the index route
router.GET("/", showIndexPage)
router.GET("/dbs", showDBSPage)
router.GET("/advanced", showAdvancedIdentityProfilePage)
router.GET("/success", showSuccessPage)
router.GET("/media", getMedia)
router.GET("/privacy-policy", showPrivacyPolicyPage)
Expand Down
66 changes: 59 additions & 7 deletions _examples/idv/templates/success.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,35 @@ <h2>Identity Profile</h2>
{{ end }}
{{ end }}
{{ end }}
{{ if .getSessionResult.AdvancedIdentityProfileResponse }}
<div class="row pt-4">
<div class="col">
<h2>Advanced Identity Profile</h2>
</div>
</div>
{{ $media := index .getSessionResult.AdvancedIdentityProfileResponse.Report "media"}}
{{ if $media }}
{{ $media_id := index $media "id" }}
{{ if $media_id }}
<div class="row pt-4">
<div class="col">
<table class="table table-striped table-light">
<tbody>
<tr>
<td>ID</td>
<td>
<a href='/media?mediaId={{ $media_id }}'>
{{ $media_id }}
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
{{ end }}
{{ end }}
{{ end }}
{{ if .getSessionResult.IdentityProfilePreview }}
<div class="row pt-4">
<div class="col">
Expand All @@ -99,6 +128,29 @@ <h2>Identity Profile Preview</h2>
</div>
</div>
{{ end }}
{{ if .getSessionResult.AdvancedIdentityProfilePreview }}
<div class="row pt-4">
<div class="col">
<h2>Advanced Identity Profile Preview</h2>
</div>
</div>
<div class="row pt-4">
<div class="col">
<table class="table table-striped table-light">
<tbody>
<tr>
<td>ID</td>
<td>
<a href='/media?mediaId={{ .getSessionResult.AdvancedIdentityProfilePreview.Media.ID }}'>
{{ .getSessionResult.AdvancedIdentityProfilePreview.Media.ID }}
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
{{ end }}
{{ if .getSessionResult.ImportTokenResponse }}
<div class="row pt-4">
<div class="col">
Expand Down Expand Up @@ -812,15 +864,15 @@ <h2>Static Liveness Resources</h2>
<tr>
<td>ID</td>
<td>{{ $liveness.ID }}

</td>
</tr>

</tbody>
</table>

<div class="accordion mt-3">

<div class="card">
<div class="card-header" id="liveness-{{ $livenessNum }}-frames">
<h3 class="mb-0">
Expand All @@ -835,18 +887,18 @@ <h3 class="mb-0">
<div id="collapse-liveness-{{ $livenessNum }}-frames" class="collapse"
aria-labelledby="liveness-{{ $livenessNum }}-frames">
<div class="card-group">

<div class="card">
<img class="card-img-top"
src="/media?mediaId={{ $liveness.Image.Media.ID }}"/>
</div>

</div>
</div>
</div>

</div>

</div>
</div>
{{ end }}
Expand Down
65 changes: 65 additions & 0 deletions _examples/profile/advancedIdentityProfile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package main

import (
"context"
"fmt"
"net/http"

"github.com/getyoti/yoti-go-sdk/v3/dynamic"
)

func advancedIdentityProfile(w http.ResponseWriter, req *http.Request) {
advancedIdentityProfile := []byte(`{
"profiles": [
{
"trust_framework": "UK_TFIDA",
"schemes": [
{
"label": "LB912",
"type": "RTW"
}
]
},
{
"trust_framework": "YOTI_GLOBAL",
"schemes": [
{
"label": "LB321",
"type": "IDENTITY",
"objective": "AL_L1"
}
]
}
]
}`)

policy, err := (&dynamic.PolicyBuilder{}).
WithAdvancedIdentityProfileRequirements(advancedIdentityProfile).
Build()
if err != nil {
errorPage(w, req.WithContext(context.WithValue(
req.Context(),
contextKey("yotiError"),
fmt.Sprintf(scenarioBuilderErr, err),
)))
return
}

subject := []byte(`{
"subject_id": "my_subject_id"
}`)
scenario, err := (&dynamic.ScenarioBuilder{}).
WithPolicy(policy).
WithSubject(subject).
WithCallbackEndpoint(profileEndpoint).Build()
if err != nil {
errorPage(w, req.WithContext(context.WithValue(
req.Context(),
contextKey("yotiError"),
fmt.Sprintf(scenarioBuilderErr, err),
)))
return
}

pageFromScenario(w, req, "Advanced Identity Profile Example", scenario)
}
1 change: 1 addition & 0 deletions _examples/profile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func main() {
http.HandleFunc("/dynamic-share", dynamicShare)
http.HandleFunc("/source-constraints", sourceConstraints)
http.HandleFunc("/dbs-check", dbsCheck)
http.HandleFunc("/advanced", advancedIdentityProfile)

rootdir, err := os.Getwd()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion consts/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package consts

const (
SDKIdentifier = "Go"
SDKVersionIdentifier = "3.10.0"
SDKVersionIdentifier = "3.11.0"
)
8 changes: 8 additions & 0 deletions docscan/session/create/sdk_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type SDKConfig struct {
ErrorUrl string `json:"error_url,omitempty"`
PrivacyPolicyUrl string `json:"privacy_policy_url,omitempty"`
AttemptsConfiguration *AttemptsConfiguration `json:"attempts_configuration,omitempty"`
AllowHandOff bool `json:"allow_handoff,omitempty"`
}

type AttemptsConfiguration struct {
Expand All @@ -37,6 +38,7 @@ type SdkConfigBuilder struct {
errorUrl string
privacyPolicyUrl string
idDocumentTextDataExtractionAttempts map[string]int
allowHandOff bool
}

// WithAllowedCaptureMethods sets the allowed capture methods on the builder
Expand Down Expand Up @@ -119,6 +121,11 @@ func (b *SdkConfigBuilder) WithIdDocumentTextExtractionGenericAttempts(attempts
return b.WithIdDocumentTextExtractionCategoryAttempts(generic, attempts)
}

func (b *SdkConfigBuilder) WithAllowHandOff(allowHandOff bool) *SdkConfigBuilder {
b.allowHandOff = allowHandOff
return b
}

// Build builds the SDKConfig struct using the supplied values
func (b *SdkConfigBuilder) Build() (*SDKConfig, error) {
sdkConf := &SDKConfig{
Expand All @@ -132,6 +139,7 @@ func (b *SdkConfigBuilder) Build() (*SDKConfig, error) {
b.errorUrl,
b.privacyPolicyUrl,
nil,
b.allowHandOff,
}

if b.idDocumentTextDataExtractionAttempts != nil {
Expand Down
20 changes: 20 additions & 0 deletions docscan/session/create/sdk_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,23 @@ func ExampleSdkConfigBuilder_WithAllowsCameraAndUpload() {
fmt.Println(string(data))
// Output: {"allowed_capture_methods":"CAMERA_AND_UPLOAD"}
}

func ExampleSdkConfigBuilder_WithAllowHandOff() {
sdkConfig, err := NewSdkConfigBuilder().
WithAllowHandOff(true).
Build()

if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

data, err := json.Marshal(sdkConfig)
if err != nil {
fmt.Printf("error: %s", err.Error())
return
}

fmt.Println(string(data))
// Output: {"allow_handoff":true}
}
Loading

0 comments on commit 3437a1d

Please sign in to comment.