digitalidentity

package
v3.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	AttrConstApplicationName           = "application_name"
	AttrConstApplicationURL            = "application_url"
	AttrConstApplicationReceiptBGColor = "application_receipt_bgcolor"
)

Attribute names for application attributes

View Source
const (
	AnchorDrivingLicenceConst = "DRIVING_LICENCE"
	AnchorPassportConst       = "PASSPORT"
	AnchorNationalIDConst     = "NATIONAL_ID"
	AnchorPassCardConst       = "PASS_CARD"
)

Anchor name constants

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationContent

type ApplicationContent struct {
	ApplicationProfile ApplicationProfile
	ExtraData          *extra.Data
}

type ApplicationProfile

type ApplicationProfile struct {
	// contains filtered or unexported fields
}

ApplicationProfile is the profile of an application with convenience methods to access well-known attributes.

func (p ApplicationProfile) ApplicationLogo() *attribute.ImageAttribute

ApplicationLogo is the logo of the application that will be displayed to those users that perform a share with it.

func (ApplicationProfile) ApplicationName

func (p ApplicationProfile) ApplicationName() *attribute.StringAttribute

ApplicationName is the name of the application

func (ApplicationProfile) ApplicationReceiptBgColor

func (p ApplicationProfile) ApplicationReceiptBgColor() *attribute.StringAttribute

ApplicationReceiptBgColor is the background colour that will be displayed on each receipt the user gets as a result of a share with the application.

func (ApplicationProfile) ApplicationURL

func (p ApplicationProfile) ApplicationURL() *attribute.StringAttribute

ApplicationURL is the URL where the application is available at

func (ApplicationProfile) GetAttribute

func (p ApplicationProfile) GetAttribute(attributeName string) *attribute.GenericAttribute

GetAttribute retrieve an attribute by name on the Yoti profile. Will return nil if attribute is not present.

func (ApplicationProfile) GetAttributeByID

func (p ApplicationProfile) GetAttributeByID(attributeID string) *attribute.GenericAttribute

GetAttributeByID retrieve an attribute by ID on the Yoti profile. Will return nil if attribute is not present.

func (ApplicationProfile) GetAttributes

func (p ApplicationProfile) GetAttributes(attributeName string) []*attribute.GenericAttribute

GetAttributes retrieve a list of attributes by name on the Yoti profile. Will return an empty list of attribute is not present.

func (ApplicationProfile) GetImageAttribute

func (p ApplicationProfile) GetImageAttribute(attributeName string) *attribute.ImageAttribute

GetImageAttribute retrieves an image attribute by name. Will return nil if attribute is not present.

func (ApplicationProfile) GetJSONAttribute

func (p ApplicationProfile) GetJSONAttribute(attributeName string) (*attribute.JSONAttribute, error)

GetJSONAttribute retrieves a JSON attribute by name. Will return nil if attribute is not present.

func (ApplicationProfile) GetStringAttribute

func (p ApplicationProfile) GetStringAttribute(attributeName string) *attribute.StringAttribute

GetStringAttribute retrieves a string attribute by name. Will return nil if attribute is not present.

type Content

type Content struct {
	Profile   []byte `json:"profile"`
	ExtraData []byte `json:"extraData"`
}

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

Policy represents a dynamic policy for a share

func (*Policy) MarshalJSON

func (policy *Policy) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type PolicyBuilder

type PolicyBuilder struct {
	// contains filtered or unexported fields
}

PolicyBuilder constructs a json payload specifying the dynamic policy for a dynamic scenario

Example
policy, err := (&PolicyBuilder{}).WithFullName().
	WithPinAuth().WithWantedRememberMe().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"full_name","accept_self_asserted":false}],"wanted_auth_types":[2],"wanted_remember_me":true}

func (*PolicyBuilder) Build

func (b *PolicyBuilder) Build() (Policy, error)

Build constructs a dynamic policy object

func (*PolicyBuilder) WithAdvancedIdentityProfileRequirements

func (b *PolicyBuilder) WithAdvancedIdentityProfileRequirements(advancedIdentityProfile json.RawMessage) *PolicyBuilder

WithAdvancedIdentityProfileRequirements adds Advanced Identity Profile Requirements to the policy. Must be valid JSON.

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

policy, err := (&PolicyBuilder{}).WithAdvancedIdentityProfileRequirements(advancedIdentityProfile).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[],"wanted_auth_types":[],"wanted_remember_me":false,"advanced_identity_profile_requirements":{"profiles":[{"trust_framework":"UK_TFIDA","schemes":[{"label":"LB912","type":"RTW"},{"label":"LB777","type":"DBS","objective":"BASIC"}]},{"trust_framework":"YOTI_GLOBAL","schemes":[{"label":"LB321","type":"IDENTITY","objective":"AL_L1","config":{}}]}]}}

func (*PolicyBuilder) WithAgeDerivedAttribute

func (b *PolicyBuilder) WithAgeDerivedAttribute(derivation string, options ...interface{}) *PolicyBuilder

WithAgeDerivedAttribute is a helper method for setting age based derivations Prefer to use WithAgeOver and WithAgeUnder instead of using this directly. "options" allows one or more options to be specified e.g. SourceConstraint

func (*PolicyBuilder) WithAgeOver

func (b *PolicyBuilder) WithAgeOver(age int, options ...interface{}) *PolicyBuilder

WithAgeOver sets this dynamic policy as requesting whether the user is older than a certain age. "options" allows one or more options to be specified e.g. SourceConstraint

Example
constraint, err := (&SourceConstraintBuilder{}).WithDrivingLicence("").Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

policy, err := (&PolicyBuilder{}).WithAgeOver(18, constraint).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := policy.attributes[0].MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"name":"date_of_birth","derivation":"age_over:18","constraints":[{"type":"SOURCE","preferred_sources":{"anchors":[{"name":"DRIVING_LICENCE","sub_type":""}],"soft_preference":false}}],"accept_self_asserted":false}

func (*PolicyBuilder) WithAgeUnder

func (b *PolicyBuilder) WithAgeUnder(age int, options ...interface{}) *PolicyBuilder

WithAgeUnder sets this dynamic policy as requesting whether the user is younger than a certain age, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithAgeUnder(18).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"date_of_birth","derivation":"age_under:18","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithDateOfBirth

func (b *PolicyBuilder) WithDateOfBirth(options ...interface{}) *PolicyBuilder

WithDateOfBirth adds the date of birth attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithDateOfBirth().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"date_of_birth","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithDocumentDetails

func (b *PolicyBuilder) WithDocumentDetails(options ...interface{}) *PolicyBuilder

WithDocumentDetails adds the document details attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithDocumentDetails().Build()
if err != nil {
	return
}
data, err := policy.attributes[0].MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"name":"document_details","accept_self_asserted":false}

func (*PolicyBuilder) WithDocumentImages

func (b *PolicyBuilder) WithDocumentImages(options ...interface{}) *PolicyBuilder

WithDocumentImages adds the document images attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithDocumentImages().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := policy.attributes[0].MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"name":"document_images","accept_self_asserted":false}

func (*PolicyBuilder) WithEmail

func (b *PolicyBuilder) WithEmail(options ...interface{}) *PolicyBuilder

WithEmail adds the email address attribute, "options" allows one or more options to be specified e.g. SourceConstraint

func (*PolicyBuilder) WithFamilyName

func (b *PolicyBuilder) WithFamilyName(options ...interface{}) *PolicyBuilder

WithFamilyName adds the family name attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithFamilyName().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := policy.attributes[0].MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"name":"family_name","accept_self_asserted":false}

func (*PolicyBuilder) WithFullName

func (b *PolicyBuilder) WithFullName(options ...interface{}) *PolicyBuilder

WithFullName adds the full name attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
constraint, err := (&SourceConstraintBuilder{}).WithPassport("").Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

policy, err := (&PolicyBuilder{}).WithFullName(&constraint).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(marshalledJSON))
Output:

{"wanted":[{"name":"full_name","constraints":[{"type":"SOURCE","preferred_sources":{"anchors":[{"name":"PASSPORT","sub_type":""}],"soft_preference":false}}],"accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithGender

func (b *PolicyBuilder) WithGender(options ...interface{}) *PolicyBuilder

WithGender adds the gender attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithGender().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"gender","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithGivenNames

func (b *PolicyBuilder) WithGivenNames(options ...interface{}) *PolicyBuilder

WithGivenNames adds the given names attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithGivenNames().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"given_names","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithIdentityProfileRequirements

func (b *PolicyBuilder) WithIdentityProfileRequirements(identityProfile json.RawMessage) *PolicyBuilder

WithIdentityProfileRequirements adds Identity Profile Requirements to the policy. Must be valid JSON.

func (*PolicyBuilder) WithNationality

func (b *PolicyBuilder) WithNationality(options ...interface{}) *PolicyBuilder

WithNationality adds the nationality attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithNationality().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"nationality","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithPhoneNumber

func (b *PolicyBuilder) WithPhoneNumber(options ...interface{}) *PolicyBuilder

WithPhoneNumber adds the phone number attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithPhoneNumber().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"phone_number","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithPinAuth

func (b *PolicyBuilder) WithPinAuth() *PolicyBuilder

WithPinAuth sets this dynamic policy as requiring PIN authentication

func (*PolicyBuilder) WithPostalAddress

func (b *PolicyBuilder) WithPostalAddress(options ...interface{}) *PolicyBuilder

WithPostalAddress adds the postal address attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithPostalAddress().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"postal_address","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithSelfie

func (b *PolicyBuilder) WithSelfie(options ...interface{}) *PolicyBuilder

WithSelfie adds the selfie attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithSelfie().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

data, err := policy.attributes[0].MarshalJSON()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(data))
Output:

{"name":"selfie","accept_self_asserted":false}

func (*PolicyBuilder) WithSelfieAuth

func (b *PolicyBuilder) WithSelfieAuth() *PolicyBuilder

WithSelfieAuth sets this dynamic policy as requiring Selfie-based authentication

Example
policy, err := (&PolicyBuilder{}).WithSelfieAuth().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[],"wanted_auth_types":[1],"wanted_remember_me":false}

func (*PolicyBuilder) WithStructuredPostalAddress

func (b *PolicyBuilder) WithStructuredPostalAddress(options ...interface{}) *PolicyBuilder

WithStructuredPostalAddress adds the structured postal address attribute, "options" allows one or more options to be specified e.g. SourceConstraint

Example
policy, err := (&PolicyBuilder{}).WithStructuredPostalAddress().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[{"name":"structured_postal_address","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false}

func (*PolicyBuilder) WithWantedAttribute

func (b *PolicyBuilder) WithWantedAttribute(attribute WantedAttribute) *PolicyBuilder

WithWantedAttribute adds an attribute from WantedAttributeBuilder to the policy

func (*PolicyBuilder) WithWantedAttributeByName

func (b *PolicyBuilder) WithWantedAttributeByName(name string, options ...interface{}) *PolicyBuilder

WithWantedAttributeByName adds an attribute by its name. This is not the preferred way of adding an attribute - instead use the other methods below. Options allows one or more options to be specified e.g. SourceConstraint

func (*PolicyBuilder) WithWantedAuthType

func (b *PolicyBuilder) WithWantedAuthType(wantedAuthType int) *PolicyBuilder

WithWantedAuthType sets this dynamic policy as requiring a specific authentication type

func (*PolicyBuilder) WithWantedRememberMe

func (b *PolicyBuilder) WithWantedRememberMe() *PolicyBuilder

WithWantedRememberMe sets the Policy as requiring a "Remember Me ID"

Example
policy, err := (&PolicyBuilder{}).WithWantedRememberMe().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"wanted":[],"wanted_auth_types":[],"wanted_remember_me":true}

type QrCode

type QrCode struct {
	Id  string `json:"id"`
	Uri string `json:"uri"`
}

func CreateShareQrCode

func CreateShareQrCode(httpClient requests.HttpClient, sessionID string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (*QrCode, error)

CreateShareQrCode generates a sharing qr code using the supplied sessionID parameter

type ReceiptItemKeyResponse

type ReceiptItemKeyResponse struct {
	ID    string `json:"id"`
	Iv    []byte `json:"iv"`
	Value []byte `json:"value"`
}

type ReceiptResponse

type ReceiptResponse struct {
	ID                 string   `json:"id"`
	SessionID          string   `json:"sessionId"`
	Timestamp          string   `json:"timestamp"`
	RememberMeID       string   `json:"rememberMeId,omitempty"`
	ParentRememberMeID string   `json:"parentRememberMeId,omitempty"`
	Content            *Content `json:"content,omitempty"`
	OtherPartyContent  *Content `json:"otherPartyContent,omitempty"`
	WrappedItemKeyId   string   `json:"wrappedItemKeyId"`
	WrappedKey         []byte   `json:"wrappedKey"`
	Error              string   `json:"error"`
}

type ShareSession

type ShareSession struct {
	Id      string   `json:"id"`
	Status  string   `json:"status"`
	Expiry  string   `json:"expiry"`
	Created string   `json:"created"`
	Updated string   `json:"updated"`
	QrCode  qrCode   `json:"qrCode"`
	Receipt *receipt `json:"receipt"`
}

ShareSession contains information about the session.

func CreateShareSession

func CreateShareSession(httpClient requests.HttpClient, shareSessionRequest *ShareSessionRequest, clientSdkId, apiUrl string, key *rsa.PrivateKey) (*ShareSession, error)

CreateShareSession creates session using the supplied session specification

Example
key := test.GetValidKey("../test/test-key.pem")

client := &mockHTTPClient{
	do: func(*http.Request) (*http.Response, error) {
		return &http.Response{
			StatusCode: 201,
			Body:       io.NopCloser(strings.NewReader(`{"id":"0","status":"success","expiry": ""}`)),
		}, nil
	},
}

policy, err := (&PolicyBuilder{}).WithFullName().WithWantedRememberMe().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

session, err := (&ShareSessionRequestBuilder{}).WithPolicy(policy).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

result, err := CreateShareSession(client, &session, "sdkId", "https://apiurl", key)

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

fmt.Printf("Status code: %s", result.Status)
Output:

Status code: success

func GetShareSession

func GetShareSession(httpClient requests.HttpClient, sessionID string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (*ShareSession, error)

GetShareSession get session info using the supplied sessionID parameter

type ShareSessionCreated

type ShareSessionCreated struct {
	ID     string `json:"id"`
	Satus  string `json:"status"`
	Expiry string `json:"expiry"`
}

ShareSessionCreated Share Session QR Result

type ShareSessionFetchedQrCode

type ShareSessionFetchedQrCode struct {
	ID          string              `json:"id"`
	Expiry      string              `json:"expiry"`
	Policy      string              `json:"policy"`
	Extensions  []interface{}       `json:"extensions"`
	Session     ShareSessionCreated `json:"session"`
	RedirectURI string              `json:"redirectUri"`
}

type ShareSessionNotification

type ShareSessionNotification struct {
	// contains filtered or unexported fields
}

ShareSessionNotification specifies the session notification configuration.

func (*ShareSessionNotification) MarshalJSON

func (a *ShareSessionNotification) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type ShareSessionNotificationBuilder

type ShareSessionNotificationBuilder struct {
	// contains filtered or unexported fields
}

ShareSessionNotificationBuilder builds Share Session Notification

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

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

fmt.Println(string(data))
Output:

{"url":""}

func (*ShareSessionNotificationBuilder) Build

Build constructs the Share Session Notification Builder

func (*ShareSessionNotificationBuilder) WithHeaders

WithHeaders set headers to Share Session Notification

Example
headers := make(map[string][]string)
headers["key"] = append(headers["key"], "value")

shareSessionNotify, err := (&ShareSessionNotificationBuilder{}).WithHeaders(headers).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"url":"","headers":{"key":["value"]}}

func (*ShareSessionNotificationBuilder) WithMethod

WithMethod set method to Share Session Notification

Example
shareSessionNotify, err := (&ShareSessionNotificationBuilder{}).WithMethod("CUSTOMMETHOD").Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"url":"","method":"CUSTOMMETHOD"}

func (*ShareSessionNotificationBuilder) WithUrl

WithUrl setsUrl to Share Session Notification

Example
shareSessionNotify, err := (&ShareSessionNotificationBuilder{}).WithUrl("Custom_Url").Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"url":"Custom_Url"}

func (*ShareSessionNotificationBuilder) WithVerifyTls

WithVerifyTLS sets whether TLS should be verified for notifications.

Example
shareSessionNotify, err := (&ShareSessionNotificationBuilder{}).WithVerifyTls(true).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"url":"","verifyTls":true}

type ShareSessionQrCode

type ShareSessionQrCode struct {
	ID         string        `json:"id"`
	Expiry     string        `json:"expiry"`
	Policy     string        `json:"policy"`
	Extensions []interface{} `json:"extensions"`
	Session    struct {
		ID     string `json:"id"`
		Status string `json:"status"`
		Expiry string `json:"expiry"`
	} `json:"session"`
	RedirectURI string `json:"redirectUri"`
}

func GetShareSessionQrCode

func GetShareSessionQrCode(httpClient requests.HttpClient, qrCodeId string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (fetchedQrCode ShareSessionQrCode, err error)

GetShareSessionQrCode is used to fetch the qr code by id.

type ShareSessionRequest

type ShareSessionRequest struct {
	// contains filtered or unexported fields
}

ShareSessionRequest represents a sharesession

func (ShareSessionRequest) MarshalJSON

func (shareSesssion ShareSessionRequest) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type ShareSessionRequestBuilder

type ShareSessionRequestBuilder struct {
	// contains filtered or unexported fields
}

ShareSessionRequestBuilder builds a session

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

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

fmt.Println(string(data))
Output:

{"policy":{"wanted":null,"wanted_auth_types":null,"wanted_remember_me":false},"extensions":[],"redirectUri":""}

func (*ShareSessionRequestBuilder) Build

Build constructs the ShareSession

func (*ShareSessionRequestBuilder) WithExtension

func (builder *ShareSessionRequestBuilder) WithExtension(extension interface{}) *ShareSessionRequestBuilder

WithExtension adds an extension to the ShareSession

Example
policy, err := (&PolicyBuilder{}).WithFullName().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

builtExtension, err := (&extension.TransactionalFlowExtensionBuilder{}).
	WithContent("Transactional Flow Extension").
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

session, err := (&ShareSessionRequestBuilder{}).WithExtension(builtExtension).WithPolicy(policy).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"policy":{"wanted":[{"name":"full_name","accept_self_asserted":false}],"wanted_auth_types":[],"wanted_remember_me":false},"extensions":[{"type":"TRANSACTIONAL_FLOW","content":"Transactional Flow Extension"}],"redirectUri":""}

func (*ShareSessionRequestBuilder) WithNotification

func (builder *ShareSessionRequestBuilder) WithNotification(notification *ShareSessionNotification) *ShareSessionRequestBuilder

WithNotification sets the callback URL

func (*ShareSessionRequestBuilder) WithPolicy

func (builder *ShareSessionRequestBuilder) WithPolicy(policy Policy) *ShareSessionRequestBuilder

WithPolicy attaches a Policy to the ShareSession

Example
policy, err := (&PolicyBuilder{}).WithEmail().WithPinAuth().Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

session, err := (&ShareSessionRequestBuilder{}).WithPolicy(policy).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"policy":{"wanted":[{"name":"email_address","accept_self_asserted":false}],"wanted_auth_types":[2],"wanted_remember_me":false},"extensions":[],"redirectUri":""}

func (*ShareSessionRequestBuilder) WithRedirectUri

func (builder *ShareSessionRequestBuilder) WithRedirectUri(redirectUri string) *ShareSessionRequestBuilder

WithRedirectUri sets redirectUri to the ShareSession

func (*ShareSessionRequestBuilder) WithSubject

WithSubject adds a subject to the ShareSession. Must be valid JSON.

Example
subject := []byte(`{
		"subject_id": "some_subject_id_string"
	}`)

session, err := (&ShareSessionRequestBuilder{}).WithSubject(subject).Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(data))
Output:

{"policy":{"wanted":null,"wanted_auth_types":null,"wanted_remember_me":false},"extensions":[],"redirectUri":"","subject":{"subject_id":"some_subject_id_string"}}

type SharedReceiptResponse

type SharedReceiptResponse struct {
	ID                 string
	SessionID          string
	RememberMeID       string
	ParentRememberMeID string
	Timestamp          string
	Error              string
	UserContent        UserContent
	ApplicationContent ApplicationContent
}

func GetShareReceipt

func GetShareReceipt(httpClient requests.HttpClient, receiptId string, clientSdkId, apiUrl string, key *rsa.PrivateKey) (receipt SharedReceiptResponse, err error)

type SourceConstraint

type SourceConstraint struct {
	// contains filtered or unexported fields
}

SourceConstraint describes a requirement or preference for a particular set of anchors

func (*SourceConstraint) MarshalJSON

func (constraint *SourceConstraint) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type SourceConstraintBuilder

type SourceConstraintBuilder struct {
	// contains filtered or unexported fields
}

SourceConstraintBuilder builds a source constraint

func (*SourceConstraintBuilder) Build

Build builds a SourceConstraint

func (*SourceConstraintBuilder) WithAnchor

WithAnchor adds an anchor to the preference list

func (*SourceConstraintBuilder) WithAnchorByValue

func (b *SourceConstraintBuilder) WithAnchorByValue(value, subtype string) *SourceConstraintBuilder

WithAnchorByValue is a helper method which builds an anchor and adds it to the source constraint

func (*SourceConstraintBuilder) WithDrivingLicence

func (b *SourceConstraintBuilder) WithDrivingLicence(subtype string) *SourceConstraintBuilder

WithDrivingLicence adds a Driving Licence anchor

func (*SourceConstraintBuilder) WithNationalID

func (b *SourceConstraintBuilder) WithNationalID(subtype string) *SourceConstraintBuilder

WithNationalID adds a national ID anchor

func (*SourceConstraintBuilder) WithPasscard

func (b *SourceConstraintBuilder) WithPasscard(subtype string) *SourceConstraintBuilder

WithPasscard adds a passcard anchor

func (*SourceConstraintBuilder) WithPassport

func (b *SourceConstraintBuilder) WithPassport(subtype string) *SourceConstraintBuilder

WithPassport adds a passport anchor

func (*SourceConstraintBuilder) WithSoftPreference

func (b *SourceConstraintBuilder) WithSoftPreference(soft bool) *SourceConstraintBuilder

WithSoftPreference sets this constraint as a 'soft requirement' if the parameter is true, and a hard requirement if it is false.

type UserContent

type UserContent struct {
	UserProfile UserProfile
	ExtraData   *extra.Data
}

type UserProfile

type UserProfile struct {
	// contains filtered or unexported fields
}

UserProfile represents the details retrieved for a particular user. Consists of Yoti attributes: a small piece of information about a Yoti user such as a photo of the user or the user's date of birth.

func (UserProfile) Address

func (p UserProfile) Address() *attribute.StringAttribute

Address represents the user's address. Will be nil if not provided by Yoti.

func (UserProfile) AgeVerifications

func (p UserProfile) AgeVerifications() (out []attribute.AgeVerification, err error)

AgeVerifications returns a slice of age verifications for the user. Will be an empty slice if not provided by Yoti.

func (UserProfile) DateOfBirth

func (p UserProfile) DateOfBirth() (*attribute.DateAttribute, error)

DateOfBirth represents the user's date of birth. Will be nil if not provided by Yoti. Has an err value which will be filled if there is an error parsing the date.

func (UserProfile) DocumentDetails

func (p UserProfile) DocumentDetails() (*attribute.DocumentDetailsAttribute, error)

DocumentDetails represents information extracted from a document provided by the user. Will be nil if not provided by Yoti.

func (UserProfile) DocumentImages

func (p UserProfile) DocumentImages() (*attribute.ImageSliceAttribute, error)

DocumentImages returns a slice of document images cropped from the image in the capture page. There can be multiple images as per the number of regions in the capture in this attribute. Will be nil if not provided by Yoti.

func (UserProfile) EmailAddress

func (p UserProfile) EmailAddress() *attribute.StringAttribute

EmailAddress represents the user's verified email address. Will be nil if not provided by Yoti.

func (UserProfile) FamilyName

func (p UserProfile) FamilyName() *attribute.StringAttribute

FamilyName corresponds to primary name in passport, and surname in English. Will be nil if not provided by Yoti.

func (UserProfile) FullName

func (p UserProfile) FullName() *attribute.StringAttribute

FullName represents the user's full name. If family_name/given_names are present, the value will be equal to the string 'given_names + " " family_name'. Will be nil if not provided by Yoti.

func (UserProfile) Gender

Gender corresponds to the gender in the registered document; the value will be one of the strings "MALE", "FEMALE", "TRANSGENDER" or "OTHER". Will be nil if not provided by Yoti.

func (UserProfile) GetAttribute

func (p UserProfile) GetAttribute(attributeName string) *attribute.GenericAttribute

GetAttribute retrieve an attribute by name on the Yoti profile. Will return nil if attribute is not present.

func (UserProfile) GetAttributeByID

func (p UserProfile) GetAttributeByID(attributeID string) *attribute.GenericAttribute

GetAttributeByID retrieve an attribute by ID on the Yoti profile. Will return nil if attribute is not present.

Example
userProfile := getUserProfile()
fullNameAttribute := userProfile.GetAttributeByID("full-name-id-123")
value := fullNameAttribute.Value().(string)

fmt.Println(value)
Output:

John Smith

func (UserProfile) GetAttributes

func (p UserProfile) GetAttributes(attributeName string) []*attribute.GenericAttribute

GetAttributes retrieve a list of attributes by name on the Yoti profile. Will return an empty list of attribute is not present.

func (UserProfile) GetDocumentImagesAttributeByID

func (p UserProfile) GetDocumentImagesAttributeByID(attributeID string) (*attribute.ImageSliceAttribute, error)

GetDocumentImagesAttributeByID retrieve a Document Images attribute by ID on the Yoti profile. This attribute consists of a slice of document images cropped from the image in the capture page. There can be multiple images as per the number of regions in the capture in this attribute. Will return nil if attribute is not present.

Example
userProfile := getUserProfile()
documentImagesAttribute, err := userProfile.GetDocumentImagesAttributeByID("document-images-attribute-id-123")
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(*documentImagesAttribute.ID())
Output:

document-images-attribute-id-123

func (UserProfile) GetImageAttribute

func (p UserProfile) GetImageAttribute(attributeName string) *attribute.ImageAttribute

GetImageAttribute retrieves an image attribute by name. Will return nil if attribute is not present.

func (UserProfile) GetJSONAttribute

func (p UserProfile) GetJSONAttribute(attributeName string) (*attribute.JSONAttribute, error)

GetJSONAttribute retrieves a JSON attribute by name. Will return nil if attribute is not present.

func (UserProfile) GetSelfieAttributeByID

func (p UserProfile) GetSelfieAttributeByID(attributeID string) (*attribute.ImageAttribute, error)

GetSelfieAttributeByID retrieve a Selfie attribute by ID on the Yoti profile. This attribute is a photograph of the user. Will return nil if attribute is not present.

Example
userProfile := getUserProfile()
selfieAttribute, err := userProfile.GetSelfieAttributeByID("selfie-attribute-id-123")
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(*selfieAttribute.ID())
Output:

selfie-attribute-id-123

func (UserProfile) GetStringAttribute

func (p UserProfile) GetStringAttribute(attributeName string) *attribute.StringAttribute

GetStringAttribute retrieves a string attribute by name. Will return nil if attribute is not present.

func (UserProfile) GivenNames

func (p UserProfile) GivenNames() *attribute.StringAttribute

GivenNames corresponds to secondary names in passport, and first/middle names in English. Will be nil if not provided by Yoti.

func (UserProfile) IdentityProfileReport

func (p UserProfile) IdentityProfileReport() (*attribute.JSONAttribute, error)

IdentityProfileReport represents the JSON object containing identity assertion and the verification report. Will be nil if not provided by Yoti.

func (UserProfile) MobileNumber

func (p UserProfile) MobileNumber() *attribute.StringAttribute

MobileNumber represents the user's mobile phone number, as verified at registration time. The value will be a number in E.164 format (i.e. '+' for international prefix and no spaces, e.g. "+447777123456"). Will be nil if not provided by Yoti.

func (UserProfile) Nationality

func (p UserProfile) Nationality() *attribute.StringAttribute

Nationality corresponds to the nationality in the passport. The value is an ISO-3166-1 alpha-3 code with ICAO9303 (passport) extensions. Will be nil if not provided by Yoti.

func (UserProfile) Selfie

func (p UserProfile) Selfie() *attribute.ImageAttribute

Selfie is a photograph of the user. Will be nil if not provided by Yoti.

func (UserProfile) StructuredPostalAddress

func (p UserProfile) StructuredPostalAddress() (*attribute.JSONAttribute, error)

StructuredPostalAddress represents the user's address in a JSON format. Will be nil if not provided by Yoti. This can be accessed as a map[string]string{} using a type assertion, e.g.: structuredPostalAddress := structuredPostalAddressAttribute.Value().(map[string]string{})

type WantedAnchor

type WantedAnchor struct {
	// contains filtered or unexported fields
}

WantedAnchor specifies a preferred anchor for a user's details

func (*WantedAnchor) MarshalJSON

func (a *WantedAnchor) MarshalJSON() ([]byte, error)

MarshalJSON ...

type WantedAnchorBuilder

type WantedAnchorBuilder struct {
	// contains filtered or unexported fields
}

WantedAnchorBuilder describes a desired anchor for user profile data

Example
aadhaarAnchor, err := (&WantedAnchorBuilder{}).
	WithValue("NATIONAL_ID").
	WithSubType("AADHAAR").
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println("Aadhaar:", string(aadhaarJSON))
Output:

Aadhaar: {"name":"NATIONAL_ID","sub_type":"AADHAAR"}

func (*WantedAnchorBuilder) Build

func (b *WantedAnchorBuilder) Build() (WantedAnchor, error)

Build constructs the anchor from the builder's specification

func (*WantedAnchorBuilder) WithSubType

func (b *WantedAnchorBuilder) WithSubType(subType string) *WantedAnchorBuilder

WithSubType sets the anchors subtype

func (*WantedAnchorBuilder) WithValue

func (b *WantedAnchorBuilder) WithValue(name string) *WantedAnchorBuilder

WithValue sets the anchor's name

type WantedAttribute

type WantedAttribute struct {
	Optional bool
	// contains filtered or unexported fields
}

WantedAttribute represents a wanted attribute in a dynamic sharing policy

func (*WantedAttribute) MarshalJSON

func (attr *WantedAttribute) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding

type WantedAttributeBuilder

type WantedAttributeBuilder struct {
	// contains filtered or unexported fields
}

WantedAttributeBuilder generates the payload for specifying a single wanted attribute as part of a dynamic scenario

Example (Optional_true)
attribute, err := (&WantedAttributeBuilder{}).
	WithName("TEST NAME").
	WithAcceptSelfAsserted(false).
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

attribute.Optional = true

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

fmt.Println(string(marshalledJSON))
Output:

{"name":"TEST NAME","accept_self_asserted":false,"optional":true}

func (*WantedAttributeBuilder) Build

func (builder *WantedAttributeBuilder) Build() (WantedAttribute, error)

Build generates the wanted attribute's specification

func (*WantedAttributeBuilder) WithAcceptSelfAsserted

func (builder *WantedAttributeBuilder) WithAcceptSelfAsserted(accept bool) *WantedAttributeBuilder

WithAcceptSelfAsserted allows self-asserted user details, such as those from Aadhar

Example
attribute, err := (&WantedAttributeBuilder{}).
	WithName("TEST NAME").
	WithAcceptSelfAsserted(true).
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(marshalledJSON))
Output:

{"name":"TEST NAME","accept_self_asserted":true}
Example (False)
attribute, err := (&WantedAttributeBuilder{}).
	WithName("TEST NAME").
	WithAcceptSelfAsserted(false).
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(marshalledJSON))
Output:

{"name":"TEST NAME","accept_self_asserted":false}

func (*WantedAttributeBuilder) WithConstraint

func (builder *WantedAttributeBuilder) WithConstraint(constraint constraintInterface) *WantedAttributeBuilder

WithConstraint adds a constraint to a wanted attribute

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

attribute, err := (&WantedAttributeBuilder{}).
	WithName("TEST NAME").
	WithConstraint(&constraint).
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

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

fmt.Println(string(marshalledJSON))
Output:

{"name":"TEST NAME","constraints":[{"type":"SOURCE","preferred_sources":{"anchors":[],"soft_preference":false}}],"accept_self_asserted":false}

func (*WantedAttributeBuilder) WithDerivation

func (builder *WantedAttributeBuilder) WithDerivation(derivation string) *WantedAttributeBuilder

WithDerivation sets the derivation

Example
attribute, err := (&WantedAttributeBuilder{}).
	WithDerivation("TEST DERIVATION").
	WithName("TEST NAME").
	Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(attribute.derivation)
Output:

TEST DERIVATION

func (*WantedAttributeBuilder) WithName

func (builder *WantedAttributeBuilder) WithName(name string) *WantedAttributeBuilder

WithName sets the name of the wanted attribute

Example
builder := (&WantedAttributeBuilder{}).WithName("TEST NAME")
attribute, err := builder.Build()
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(attribute.name)
Output:

TEST NAME

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL