sandbox

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 11 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      string
	Value     string
	SubType   string
	Timestamp time.Time
}

Anchor describes an anchor on a Sandbox Attribute

func SourceAnchor

func SourceAnchor(subtype string, timestamp time.Time, value string) Anchor
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
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 adds an Anchor to a Sandbox Attribute

Example
time.Local = time.UTC
attribute := Attribute{
	Name:  "AttributeName",
	Value: "Value",
}.WithAnchor(SourceAnchor("", time.Unix(1234567890, 0), ""))
fmt.Println(attribute)
Output:

{AttributeName Value   [{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
	// 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 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 derivaton 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) 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) 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

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