Skip to content

Commit

Permalink
Release 3.7.0 (#243)
Browse files Browse the repository at this point in the history
* Bump gotest.tools/v3 from 3.2.0 to 3.3.0

Bumps [gotest.tools/v3](https://github.com/gotestyourself/gotest.tools) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/gotestyourself/gotest.tools/releases)
- [Commits](gotestyourself/gotest.tools@v3.2.0...v3.3.0)

---
updated-dependencies:
- dependency-name: gotest.tools/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Add identity_profile_requirements support

* Update CONTRIBUTING.md

* Fix failing tests

* Update docscan/session/create/session_spec.go

Co-authored-by: Ed Harrod <echarrod@users.noreply.github.com>

* Retrieve the identity profile in the IDV response (#239)

Co-authored-by: Iancu Fofiu <>

* Add subject to IDV session (#240)

Co-authored-by: Iancu Fofiu <>

* Add attempts configuration to IDV with relevant tests (#242)

Co-authored-by: Iancu Fofiu <>

* Fix retries to use uppercase ID_DOCUMENT_TEXT_DATA_EXTRACTION (#245)

Co-authored-by: Iancu Fofiu <>

* Added media retrieval for Identity Profiles (#246)

Co-authored-by: Iancu Fofiu <>

* Fix success.html template (#247)

Co-authored-by: Iancu Fofiu <>

* Identity profile preview (#248)

* Added support for IdentityProfilePreview

* Add IdentityProfilePreview in the example

Co-authored-by: Iancu Fofiu <>

* Renamed Retries to Attempts (#249)

Co-authored-by: Iancu Fofiu <>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Ed Harrod <echarrod@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Iancu Fofiu <>
  • Loading branch information
3 people committed Dec 7, 2022
1 parent ffeaaf8 commit b1b6d24
Show file tree
Hide file tree
Showing 28 changed files with 534 additions and 90 deletions.
38 changes: 4 additions & 34 deletions CONTRIBUTING.md
Expand Up @@ -2,38 +2,8 @@

## Commit Process

This repo comes with pre-commit hooks. We strongly recommend installing them with `pre-commit install`. This will lint and run unit tests automatically

## VS Code

For developing in VS Code, use the following `launch.json` file (placed inside a `.vscode` folder) to easily run the examples from VS Code:

```javascript
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "AML Example",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/_examples/aml/main.go"
},
{
"name": "Example",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"host": "127.0.0.1",
"program": "${workspaceFolder}/_examples/profile/main.go",
"env": {},
"args": ["certificatehelper.go"],
"showLog": true
}
]
}
This repo comes with pre-commit hooks. These should be installed before commiting, done with:
```bash
pre-commit install --hook-type pre-commit --hook-type pre-push
```
This will lint and run Go tools on commit, and run unit tests when pushing.
2 changes: 1 addition & 1 deletion _examples/aml/go.sum
Expand Up @@ -8,4 +8,4 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
2 changes: 1 addition & 1 deletion _examples/docscansandbox/go.sum
Expand Up @@ -160,7 +160,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
2 changes: 1 addition & 1 deletion _examples/idv/go.sum
Expand Up @@ -65,4 +65,4 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
26 changes: 21 additions & 5 deletions _examples/idv/handlers.session.go
Expand Up @@ -25,18 +25,21 @@ var (
)

func showIndexPage(c *gin.Context) {
err := initialiseDocScanClient()
sessionSpec, err := buildSessionSpec()
if err != nil {
c.HTML(
http.StatusUnprocessableEntity,
http.StatusInternalServerError,
"error.html",
gin.H{
"ErrorTitle": "Error initialising Doc Scan (IDV) Client",
"ErrorMessage": errors.Unwrap(err)})
"ErrorTitle": "Error when building sessions spec",
"ErrorMessage": err.Error()})
return
}
pageFromSessionSpec(c, sessionSpec)
}

sessionSpec, err := buildSessionSpec()
func showDBSPage(c *gin.Context) {
sessionSpec, err := buildDBSSessionSpec()
if err != nil {
c.HTML(
http.StatusInternalServerError,
Expand All @@ -46,7 +49,20 @@ func showIndexPage(c *gin.Context) {
"ErrorMessage": err.Error()})
return
}
pageFromSessionSpec(c, sessionSpec)
}

func pageFromSessionSpec(c *gin.Context, sessionSpec *create.SessionSpecification) {
err := initialiseDocScanClient()
if err != nil {
c.HTML(
http.StatusUnprocessableEntity,
"error.html",
gin.H{
"ErrorTitle": "Error initialising Doc Scan (IDV) Client",
"ErrorMessage": errors.Unwrap(err)})
return
}
createSessionResult, err = client.CreateSession(sessionSpec)
if err != nil {
c.HTML(
Expand Down
11 changes: 11 additions & 0 deletions _examples/idv/main.go
Expand Up @@ -3,6 +3,9 @@
package main

import (
"encoding/json"
"fmt"
"html/template"
"net/http"

"github.com/gin-gonic/gin"
Expand All @@ -17,6 +20,14 @@ func main() {
// Set the router as the default one provided by Gin
router = gin.Default()

router.SetFuncMap(template.FuncMap{
"jsonMarshallIndent": func(data interface{}) string {
json, err := json.MarshalIndent(data, "", "\t")
if err != nil {
fmt.Println(err)
}
return string(json)
}})
// Process the templates at the start so that they don't have to be loaded
// from the disk again. This makes serving HTML pages very fast.
router.LoadHTMLGlob("templates/*")
Expand Down
46 changes: 46 additions & 0 deletions _examples/idv/models.sessionspec.go
Expand Up @@ -94,6 +94,7 @@ func buildSessionSpec() (sessionSpec *create.SessionSpecification, err error) {
WithSuccessUrl("https://localhost:8080/success").
WithErrorUrl("https://localhost:8080/error").
WithPrivacyPolicyUrl("https://localhost:8080/privacy-policy").
WithIdDocumentTextExtractionGenericAttempts(2).
Build()
if err != nil {
return nil, err
Expand Down Expand Up @@ -154,3 +155,48 @@ func buildSessionSpec() (sessionSpec *create.SessionSpecification, err error) {
}
return sessionSpec, nil
}

func buildDBSSessionSpec() (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
}

identityProfile := []byte(`{
"trust_framework": "UK_TFIDA",
"scheme": {
"type": "DBS",
"objective": "BASIC"
}
}`)

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

sessionSpec, err = create.NewSessionSpecificationBuilder().
WithClientSessionTokenTTL(6000).
WithResourcesTTL(900000).
WithUserTrackingID("some-tracking-id").
WithSDKConfig(sdkConfig).
WithIdentityProfileRequirements(identityProfile).
WithCreateIdentityProfilePreview(true).
WithSubject(subject).
Build()

if err != nil {
return nil, err
}
return sessionSpec, nil
}
1 change: 1 addition & 0 deletions _examples/idv/routes.go
Expand Up @@ -8,6 +8,7 @@ func initializeRoutes() {

// Handle the index route
router.GET("/", showIndexPage)
router.GET("/dbs", showDBSPage)
router.GET("/success", showSuccessPage)
router.GET("/media", getMedia)
router.GET("/privacy-policy", showPrivacyPolicyPage)
Expand Down
52 changes: 52 additions & 0 deletions _examples/idv/templates/success.html
Expand Up @@ -47,6 +47,58 @@ <h1>Get Session Result</h1>
</div>
</div>

{{ if .getSessionResult.IdentityProfileResponse }}
<div class="row pt-4">
<div class="col">
<h2>Identity Profile</h2>
</div>
</div>
{{ $media := index .getSessionResult.IdentityProfileResponse.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">
<h2>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.IdentityProfilePreview.Media.ID }}'>
{{ .getSessionResult.IdentityProfilePreview.Media.ID }}
</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
{{ end }}
{{ if .getSessionResult.Checks }}
<div class="row pt-4">
<div class="col">
Expand Down
2 changes: 1 addition & 1 deletion _examples/profile/go.sum
Expand Up @@ -8,4 +8,4 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
2 changes: 1 addition & 1 deletion _examples/profilesandbox/go.mod
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/getyoti/yoti-go-sdk/v3 v3.0.0
github.com/joho/godotenv v1.3.0
gotest.tools/v3 v3.2.0
gotest.tools/v3 v3.3.0
)

require (
Expand Down
4 changes: 2 additions & 2 deletions _examples/profilesandbox/go.sum
Expand Up @@ -31,5 +31,5 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
gotest.tools/v3 v3.2.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
2 changes: 1 addition & 1 deletion consts/version.go
Expand Up @@ -2,5 +2,5 @@ package consts

const (
SDKIdentifier = "Go"
SDKVersionIdentifier = "3.6.0"
SDKVersionIdentifier = "3.7.0"
)
6 changes: 6 additions & 0 deletions docscan/session/create/constants.go
@@ -0,0 +1,6 @@
package create

const (
reclassification string = "RECLASSIFICATION"
generic string = "GENERIC"
)
70 changes: 50 additions & 20 deletions docscan/session/create/sdk_config.go
Expand Up @@ -4,15 +4,20 @@ import "github.com/getyoti/yoti-go-sdk/v3/docscan/constants"

// SDKConfig provides configuration properties for the the web/native clients
type SDKConfig struct {
AllowedCaptureMethods string `json:"allowed_capture_methods,omitempty"`
PrimaryColour string `json:"primary_colour,omitempty"`
SecondaryColour string `json:"secondary_colour,omitempty"`
FontColour string `json:"font_colour,omitempty"`
Locale string `json:"locale,omitempty"`
PresetIssuingCountry string `json:"preset_issuing_country,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
ErrorUrl string `json:"error_url,omitempty"`
PrivacyPolicyUrl string `json:"privacy_policy_url,omitempty"`
AllowedCaptureMethods string `json:"allowed_capture_methods,omitempty"`
PrimaryColour string `json:"primary_colour,omitempty"`
SecondaryColour string `json:"secondary_colour,omitempty"`
FontColour string `json:"font_colour,omitempty"`
Locale string `json:"locale,omitempty"`
PresetIssuingCountry string `json:"preset_issuing_country,omitempty"`
SuccessUrl string `json:"success_url,omitempty"`
ErrorUrl string `json:"error_url,omitempty"`
PrivacyPolicyUrl string `json:"privacy_policy_url,omitempty"`
AttemptsConfiguration *AttemptsConfiguration `json:"attempts_configuration,omitempty"`
}

type AttemptsConfiguration struct {
IdDocumentTextDataExtraction map[string]int `json:"ID_DOCUMENT_TEXT_DATA_EXTRACTION,omitempty"`
}

// NewSdkConfigBuilder creates a new SdkConfigBuilder
Expand All @@ -22,15 +27,16 @@ func NewSdkConfigBuilder() *SdkConfigBuilder {

// SdkConfigBuilder builds the SDKConfig struct
type SdkConfigBuilder struct {
allowedCaptureMethods string
primaryColour string
secondaryColour string
fontColour string
locale string
presetIssuingCountry string
successUrl string
errorUrl string
privacyPolicyUrl string
allowedCaptureMethods string
primaryColour string
secondaryColour string
fontColour string
locale string
presetIssuingCountry string
successUrl string
errorUrl string
privacyPolicyUrl string
idDocumentTextDataExtractionAttempts map[string]int
}

// WithAllowedCaptureMethods sets the allowed capture methods on the builder
Expand Down Expand Up @@ -97,9 +103,25 @@ func (b *SdkConfigBuilder) WithPrivacyPolicyUrl(url string) *SdkConfigBuilder {
return b
}

func (b *SdkConfigBuilder) WithIdDocumentTextExtractionCategoryAttempts(category string, attempts int) *SdkConfigBuilder {
if b.idDocumentTextDataExtractionAttempts == nil {
b.idDocumentTextDataExtractionAttempts = make(map[string]int)
}
b.idDocumentTextDataExtractionAttempts[category] = attempts
return b
}

func (b *SdkConfigBuilder) WithIdDocumentTextExtractionReclassificationAttempts(attempts int) *SdkConfigBuilder {
return b.WithIdDocumentTextExtractionCategoryAttempts(reclassification, attempts)
}

func (b *SdkConfigBuilder) WithIdDocumentTextExtractionGenericAttempts(attempts int) *SdkConfigBuilder {
return b.WithIdDocumentTextExtractionCategoryAttempts(generic, attempts)
}

// Build builds the SDKConfig struct using the supplied values
func (b *SdkConfigBuilder) Build() (*SDKConfig, error) {
return &SDKConfig{
sdkConf := &SDKConfig{
b.allowedCaptureMethods,
b.primaryColour,
b.secondaryColour,
Expand All @@ -109,5 +131,13 @@ func (b *SdkConfigBuilder) Build() (*SDKConfig, error) {
b.successUrl,
b.errorUrl,
b.privacyPolicyUrl,
}, nil
nil,
}

if b.idDocumentTextDataExtractionAttempts != nil {
sdkConf.AttemptsConfiguration = &AttemptsConfiguration{
IdDocumentTextDataExtraction: b.idDocumentTextDataExtractionAttempts,
}
}
return sdkConf, nil
}

0 comments on commit b1b6d24

Please sign in to comment.