Documentation ¶
Index ¶
- type Anchor
- type Attribute
- type Client
- type Derivation
- type DocumentImages
- type TokenRequest
- func (t TokenRequest) WithAgeVerification(dateOfBirth time.Time, derivation Derivation, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithAttribute(name, value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithAttributeStruct(attribute Attribute) TokenRequest
- func (t TokenRequest) WithBase64Selfie(base64Value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithDateOfBirth(value time.Time, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithDocumentDetails(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithDocumentImages(value DocumentImages, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithEmailAddress(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithFamilyName(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithFullName(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithGender(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithGivenNames(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithNationality(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithPhoneNumber(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithPostalAddress(value string, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithRememberMeID(rememberMeId string) TokenRequest
- func (t TokenRequest) WithSelfie(value []byte, anchors []Anchor) TokenRequest
- func (t TokenRequest) WithStructuredPostalAddress(value map[string]interface{}, anchors []Anchor) TokenRequest
Examples ¶
- Attribute.WithAnchor
- Derivation.AgeOver
- Derivation.AgeUnder
- SourceAnchor
- TokenRequest.WithAgeVerification
- TokenRequest.WithAttribute
- TokenRequest.WithAttributeStruct
- TokenRequest.WithBase64Selfie
- TokenRequest.WithDateOfBirth
- TokenRequest.WithDocumentDetails
- TokenRequest.WithDocumentImages
- TokenRequest.WithEmailAddress
- TokenRequest.WithFamilyName
- TokenRequest.WithFullName
- TokenRequest.WithGender
- TokenRequest.WithGivenNames
- TokenRequest.WithNationality
- TokenRequest.WithPhoneNumber
- TokenRequest.WithPostalAddress
- TokenRequest.WithRememberMeID
- TokenRequest.WithSelfie
- TokenRequest.WithStructuredPostalAddress
- VerifierAnchor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anchor ¶
type Anchor struct { // Type of the Anchor - most likely either SOURCE or VERIFIER, but it's // possible that new Anchor types will be added in future. Type string // Value identifies the provider that either sourced or verified the attribute value. // The range of possible values is not limited. For a SOURCE anchor, expect values like // PASSPORT, DRIVING_LICENSE. For a VERIFIER anchor expect values like YOTI_ADMIN. Value string // SubType is an indicator of any specific processing method, or subcategory, // pertaining to an artifact. For example, for a passport, this would be // either "NFC" or "OCR". SubType string // Timestamp is the time when the anchor was created, i.e. when it was SOURCED or VERIFIED. Timestamp time.Time }
Anchor is the metadata associated with an attribute. It describes how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).
func SourceAnchor ¶
SourceAnchor initialises an anchor where the type is "SOURCE", which has information about how the anchor was sourced.
Example ¶
time.Local = time.UTC source := SourceAnchor("subtype", time.Unix(1234567890, 0), "value") marshalled, err := source.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalled))
Output: {"type":"SOURCE","value":"value","sub_type":"subtype","timestamp":1234567890000}
func VerifierAnchor ¶
VerifierAnchor initialises an anchor where the type is "VERIFIER", which has information about how the anchor was verified.
Example ¶
time.Local = time.UTC verifier := VerifierAnchor("subtype", time.Unix(1234567890, 0), "value") marshalled, err := verifier.MarshalJSON() if err != nil { fmt.Printf("error: %s", err.Error()) return } fmt.Println(string(marshalled))
Output: {"type":"VERIFIER","value":"value","sub_type":"subtype","timestamp":1234567890000}
func (*Anchor) MarshalJSON ¶
MarshalJSON returns the JSON encoding
type Attribute ¶
type Attribute struct { Name string `json:"name"` Value string `json:"value"` Derivation string `json:"derivation"` Optional string `json:"optional"` Anchors []Anchor `json:"anchors"` }
Attribute describes an attribute on a sandbox profile
func (Attribute) WithAnchor ¶
WithAnchor sets the Anchor of a Sandbox Attribute
Example ¶
time.Local = time.UTC attribute := Attribute{}.WithAnchor(SourceAnchor("", time.Unix(1234567890, 0), "")) fmt.Print(attribute)
Output: { [{SOURCE 2009-02-13 23:31:30 +0000 UTC}]}
type Client ¶
type Client struct { // Client SDK ID. This can be found in the Yoti Hub after you have created and activated an application. ClientSdkID string // Private Key associated for your application, can be downloaded from the Yoti Hub. Key *rsa.PrivateKey // Base URL to use. This is not required, and a default will be set if not provided. BaseURL string // Mockable HTTP Client Interface HTTPClient interface { Do(*http.Request) (*http.Response, error) } }
Client is responsible for setting up test data in the sandbox instance. BaseURL is not required.
func (*Client) SetupSharingProfile ¶
func (client *Client) SetupSharingProfile(tokenRequest TokenRequest) (token string, err error)
SetupSharingProfile creates a user profile in the sandbox instance
type Derivation ¶
type Derivation struct {
// contains filtered or unexported fields
}
Derivation is a builder for derivation strings
func (Derivation) AgeOver ¶
func (derivation Derivation) AgeOver(age int) Derivation
AgeOver builds an age over age derivation
Example ¶
attribute := Attribute{ Name: "date_of_birth", Value: "Value", Derivation: Derivation{}.AgeOver(18).ToString(), } fmt.Println(attribute)
Output: {date_of_birth Value age_over:18 []}
func (Derivation) AgeUnder ¶
func (derivation Derivation) AgeUnder(age int) Derivation
AgeUnder builds an age under age derivation
Example ¶
attribute := Attribute{ Name: "date_of_birth", Value: "Value", Derivation: Derivation{}.AgeUnder(14).ToString(), } fmt.Println(attribute)
Output: {date_of_birth Value age_under:14 []}
func (Derivation) ToString ¶
func (derivation Derivation) ToString() string
ToString returns the string representation for a derivation
type DocumentImages ¶
DocumentImages describes a Document Images attribute on a sandbox profile
func (DocumentImages) WithJpegImage ¶
func (d DocumentImages) WithJpegImage(imageContent []byte) DocumentImages
WithJpegImage adds a JPEG image to the slice of document images
func (DocumentImages) WithPngImage ¶
func (d DocumentImages) WithPngImage(imageContent []byte) DocumentImages
WithPngImage adds a PNG image to the slice of document images
type TokenRequest ¶
type TokenRequest struct { RememberMeID string `json:"remember_me_id"` Attributes []Attribute `json:"profile_attributes"` }
TokenRequest describes a sandbox token request
func (TokenRequest) WithAgeVerification ¶
func (t TokenRequest) WithAgeVerification(dateOfBirth time.Time, derivation Derivation, anchors []Anchor) TokenRequest
WithAgeVerification adds an age-based derivation attribute to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithAgeVerification( time.Unix(1234567890, 0), Derivation{}.AgeOver(18), AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"date_of_birth","value":"2009-02-13","derivation":"age_over:18","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithAttribute ¶
func (t TokenRequest) WithAttribute(name, value string, anchors []Anchor) TokenRequest
WithAttribute adds a new attribute to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithAttribute( "AttributeName1", "Value", AnchorList(), ).WithAttribute( "AttributeName2", "Value", nil, ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"AttributeName1","value":"Value","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]},{"name":"AttributeName2","value":"Value","derivation":"","optional":"","anchors":[]}]}
func (TokenRequest) WithAttributeStruct ¶
func (t TokenRequest) WithAttributeStruct(attribute Attribute) TokenRequest
WithAttributeStruct adds a new attribute struct to the sandbox token request
Example ¶
attribute := Attribute{ Name: "AttributeName3", Value: "Value3", Anchors: AnchorList(), } time.Local = time.UTC tokenRequest := TokenRequest{}.WithAttributeStruct(attribute) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"AttributeName3","value":"Value3","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithBase64Selfie ¶
func (t TokenRequest) WithBase64Selfie(base64Value string, anchors []Anchor) TokenRequest
WithBase64Selfie adds a base 64 selfie image to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithBase64Selfie( "3q2+7w==", AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"selfie","value":"3q2+7w==","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithDateOfBirth ¶
func (t TokenRequest) WithDateOfBirth(value time.Time, anchors []Anchor) TokenRequest
WithDateOfBirth adds a date of birth to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithDateOfBirth(time.Unix(1234567890, 0), AnchorList()) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"date_of_birth","value":"2009-02-13","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithDocumentDetails ¶
func (t TokenRequest) WithDocumentDetails(value string, anchors []Anchor) TokenRequest
WithDocumentDetails adds a document details string to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithDocumentDetails( "DRIVING_LICENCE - abc1234", AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"document_details","value":"DRIVING_LICENCE - abc1234","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithDocumentImages ¶
func (t TokenRequest) WithDocumentImages(value DocumentImages, anchors []Anchor) TokenRequest
WithDocumentImages adds document images to the sandbox token request
Example ¶
time.Local = time.UTC documentImages := DocumentImages{}.WithPngImage([]byte{0xDE, 0xAD, 0xBE, 0xEF}).WithJpegImage([]byte{0xDE, 0xAD, 0xBE, 0xEF}) tokenRequest := TokenRequest{}.WithDocumentImages( documentImages, AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"document_images","value":"data:image/png;base64,3q2+7w==\u0026data:image/jpeg;base64,3q2+7w==","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithEmailAddress ¶
func (t TokenRequest) WithEmailAddress(value string, anchors []Anchor) TokenRequest
WithEmailAddress adds an email address to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithEmailAddress("user@example.com", AnchorList()) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"email_address","value":"user@example.com","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithFamilyName ¶
func (t TokenRequest) WithFamilyName(value string, anchors []Anchor) TokenRequest
WithFamilyName adds a family name to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithFamilyName( "Value", AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"family_name","value":"Value","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithFullName ¶
func (t TokenRequest) WithFullName(value string, anchors []Anchor) TokenRequest
WithFullName adds a full name to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithFullName( "Value", AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"full_name","value":"Value","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithGender ¶
func (t TokenRequest) WithGender(value string, anchors []Anchor) TokenRequest
WithGender adds a gender to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithGender("male", AnchorList()) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"gender","value":"male","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithGivenNames ¶
func (t TokenRequest) WithGivenNames(value string, anchors []Anchor) TokenRequest
WithGivenNames adds given names to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithGivenNames( "Value", AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"given_names","value":"Value","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithNationality ¶
func (t TokenRequest) WithNationality(value string, anchors []Anchor) TokenRequest
WithNationality adds a nationality to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithNationality("Value", AnchorList()) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"nationality","value":"Value","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithPhoneNumber ¶
func (t TokenRequest) WithPhoneNumber(value string, anchors []Anchor) TokenRequest
WithPhoneNumber adds a phone number to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithPhoneNumber("00005550000", AnchorList()) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"phone_number","value":"00005550000","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithPostalAddress ¶
func (t TokenRequest) WithPostalAddress(value string, anchors []Anchor) TokenRequest
WithPostalAddress adds a formatted address to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithPostalAddress("Value", AnchorList()) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"postal_address","value":"Value","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithRememberMeID ¶
func (t TokenRequest) WithRememberMeID(rememberMeId string) TokenRequest
WithRememberMeID adds the Remember Me ID to the returned ActivityDetails. The value returned in ActivityDetails will be the Base64 encoded value of the string specified here.
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithRememberMeID("some-remember-me-id") printJson(tokenRequest)
Output: {"remember_me_id":"some-remember-me-id","profile_attributes":null}
func (TokenRequest) WithSelfie ¶
func (t TokenRequest) WithSelfie(value []byte, anchors []Anchor) TokenRequest
WithSelfie adds a selfie image to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithSelfie( []byte{0xDE, 0xAD, 0xBE, 0xEF}, AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"selfie","value":"3q2+7w==","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}
func (TokenRequest) WithStructuredPostalAddress ¶
func (t TokenRequest) WithStructuredPostalAddress(value map[string]interface{}, anchors []Anchor) TokenRequest
WithStructuredPostalAddress adds a JSON address to the sandbox token request
Example ¶
time.Local = time.UTC tokenRequest := TokenRequest{}.WithStructuredPostalAddress( map[string]interface{}{ "FormattedAddressLine": "Value", }, AnchorList(), ) printJson(tokenRequest)
Output: {"remember_me_id":"","profile_attributes":[{"name":"structured_postal_address","value":"{\"FormattedAddressLine\":\"Value\"}","derivation":"","optional":"","anchors":[{"type":"SOURCE","value":"","sub_type":"","timestamp":1234567890000},{"type":"VERIFIER","value":"","sub_type":"","timestamp":1234567890000}]}]}