sandbox

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Examples

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 valuues 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

func SourceAnchor(subtype string, timestamp time.Time, value string) Anchor

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")
fmt.Println(source)
Output:

{SOURCE value subtype 2009-02-13 23:31:30 +0000 UTC}

func VerifierAnchor

func VerifierAnchor(subtype string, timestamp time.Time, value string) Anchor

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")
fmt.Println(verifier)
Output:

{VERIFIER value subtype 2009-02-13 23:31:30 +0000 UTC}

func (*Anchor) MarshalJSON

func (anchor *Anchor) MarshalJSON() ([]byte, error)

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

func (attr Attribute) WithAnchor(anchor Anchor) Attribute

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}]}

func (Attribute) WithName added in v2.9.0

func (attr Attribute) WithName(name string) Attribute

WithName sets the value of a Sandbox Attribute

func (Attribute) WithValue added in v2.9.0

func (attr Attribute) WithValue(value string) Attribute

WithAnchor sets the value of a Sandbox Attribute

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
	// contains filtered or unexported fields
}

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 added in v2.10.0

type DocumentImages struct {
	Images []attribute.Image
}

Attribute describes an attribute on a sandbox profile

func (DocumentImages) WithJpegImage added in v2.10.0

func (d DocumentImages) WithJpegImage(imageContent []byte) DocumentImages

WithPngImage adds a JPEG image to the slice of document images

func (DocumentImages) WithPngImage added in v2.10.0

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{date_of_birth 2009-02-13 age_over:18  [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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,
)
fmt.Println(tokenRequest)
Output:

{ [{AttributeName1 Value   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]} {AttributeName2 Value   []}]}

func (TokenRequest) WithAttributeStruct added in v2.9.0

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)
fmt.Println(tokenRequest)
Output:

{ [{AttributeName3 Value3   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{selfie 3q2+7w==   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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())
fmt.Println(tokenRequest)
Output:

{ [{date_of_birth 2009-02-13   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{document_details DRIVING_LICENCE - abc1234   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

func (TokenRequest) WithDocumentImages added in v2.10.0

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{document_images data:image/png;base64,3q2+7w==&data:image/jpeg;base64,3q2+7w==   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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())
fmt.Println(tokenRequest)
Output:

{ [{email_address user@example.com   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{family_name Value   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{full_name Value   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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())
fmt.Println(tokenRequest)
Output:

{ [{gender male   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{given_names Value   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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())
fmt.Println(tokenRequest)
Output:

{ [{nationality Value   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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())
fmt.Println(tokenRequest)
Output:

{ [{phone_number 00005550000   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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())
fmt.Println(tokenRequest)
Output:

{ [{postal_address Value   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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.

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{selfie 3q2+7w==   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

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(),
)
fmt.Println(tokenRequest)
Output:

{ [{structured_postal_address {"FormattedAddressLine":"Value"}   [{SOURCE   2009-02-13 23:31:30 +0000 UTC} {VERIFIER   2009-02-13 23:31:30 +0000 UTC}]}]}

Jump to

Keyboard shortcuts

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