attribute

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: 13 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateImageSlice

func CreateImageSlice(items []*Item) (result []media.Media, err error)

CreateImageSlice takes a slice of Items, and converts them into a slice of images

Types

type AgeVerification

type AgeVerification struct {
	Age       int
	CheckType string
	Result    bool
	Attribute *yotiprotoattr.Attribute
}

AgeVerification encapsulates the result of a single age verification as part of a share

func NewAgeVerification

func NewAgeVerification(attr *yotiprotoattr.Attribute) (verification AgeVerification, err error)

NewAgeVerification constructs an AgeVerification from a protobuffer

type DateAttribute

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

DateAttribute is a Yoti attribute which returns a date as *time.Time for its value

func NewDate

NewDate creates a new Date attribute

func (DateAttribute) Anchors

func (a DateAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (DateAttribute) ContentType

func (a DateAttribute) ContentType() string

ContentType gets the attribute's content type description

func (DateAttribute) ID added in v3.6.0

func (a DateAttribute) ID() *string

ID gets the attribute ID

func (DateAttribute) Name

func (a DateAttribute) Name() string

Name gets the attribute name

func (DateAttribute) Sources

func (a DateAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*DateAttribute) Value

func (a *DateAttribute) Value() *time.Time

Value returns the value of the TimeAttribute as *time.Time

func (DateAttribute) Verifiers

func (a DateAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type Definition

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

Definition contains information about the attribute(s) issued by a third party.

func NewAttributeDefinition

func NewAttributeDefinition(s string) Definition

NewAttributeDefinition returns a new AttributeDefinition

func (Definition) MarshalJSON

func (a Definition) MarshalJSON() ([]byte, error)

MarshalJSON returns encoded json

Example
exampleDefinition := NewAttributeDefinition("exampleDefinition")
marshalledJSON, err := json.Marshal(exampleDefinition)
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Println(string(marshalledJSON))
Output:

{"name":"exampleDefinition"}

func (Definition) Name

func (a Definition) Name() string

Name of the attribute to be issued.

type DocumentDetails

type DocumentDetails struct {
	DocumentType     string
	IssuingCountry   string
	DocumentNumber   string
	ExpirationDate   *time.Time
	IssuingAuthority string
}

DocumentDetails represents information extracted from a document provided by the user

func (*DocumentDetails) Parse

func (details *DocumentDetails) Parse(data string) error

Parse fills a DocumentDetails object from a raw string

Example
raw := "PASSPORT GBR 1234567 2022-09-12"
details := DocumentDetails{}
err := details.Parse(raw)
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Printf(
	"Document Type: %s, Issuing Country: %s, Document Number: %s, Expiration Date: %s",
	details.DocumentType,
	details.IssuingCountry,
	details.DocumentNumber,
	details.ExpirationDate,
)
Output:

Document Type: PASSPORT, Issuing Country: GBR, Document Number: 1234567, Expiration Date: 2022-09-12 00:00:00 +0000 UTC

type DocumentDetailsAttribute

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

DocumentDetailsAttribute wraps a document details with anchor data

func NewDocumentDetails

func NewDocumentDetails(a *yotiprotoattr.Attribute) (*DocumentDetailsAttribute, error)

NewDocumentDetails creates a DocumentDetailsAttribute which wraps a DocumentDetails with anchor data

Example
proto := yotiprotoattr.Attribute{
	Name:        "exampleDocumentDetails",
	Value:       []byte("PASSPORT GBR 1234567 2022-09-12"),
	ContentType: yotiprotoattr.ContentType_STRING,
}
attribute, err := NewDocumentDetails(&proto)
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}

fmt.Printf(
	"Document Type: %s, With %d Anchors",
	attribute.Value().DocumentType,
	len(attribute.Anchors()),
)
Output:

Document Type: PASSPORT, With 0 Anchors

func (DocumentDetailsAttribute) Anchors

func (a DocumentDetailsAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (DocumentDetailsAttribute) ContentType

func (a DocumentDetailsAttribute) ContentType() string

ContentType gets the attribute's content type description

func (DocumentDetailsAttribute) ID added in v3.6.0

func (a DocumentDetailsAttribute) ID() *string

ID gets the attribute ID

func (DocumentDetailsAttribute) Name

func (a DocumentDetailsAttribute) Name() string

Name gets the attribute name

func (DocumentDetailsAttribute) Sources

func (a DocumentDetailsAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*DocumentDetailsAttribute) Value

Value returns the document details struct attached to this attribute

func (DocumentDetailsAttribute) Verifiers

func (a DocumentDetailsAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type GenericAttribute

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

GenericAttribute is a Yoti attribute which returns a generic value

func NewGeneric

NewGeneric creates a new generic attribute

func (GenericAttribute) Anchors

func (a GenericAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (GenericAttribute) ContentType

func (a GenericAttribute) ContentType() string

ContentType gets the attribute's content type description

func (GenericAttribute) ID added in v3.6.0

func (a GenericAttribute) ID() *string

ID gets the attribute ID

func (GenericAttribute) Name

func (a GenericAttribute) Name() string

Name gets the attribute name

func (GenericAttribute) Sources

func (a GenericAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*GenericAttribute) Value

func (a *GenericAttribute) Value() interface{}

Value returns the value of the GenericAttribute as an interface

func (GenericAttribute) Verifiers

func (a GenericAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type ImageAttribute

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

ImageAttribute is a Yoti attribute which returns an image as its value

func NewImage

NewImage creates a new Image attribute

func (ImageAttribute) Anchors

func (a ImageAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (ImageAttribute) ContentType

func (a ImageAttribute) ContentType() string

ContentType gets the attribute's content type description

func (ImageAttribute) ID added in v3.6.0

func (a ImageAttribute) ID() *string

ID gets the attribute ID

func (ImageAttribute) Name

func (a ImageAttribute) Name() string

Name gets the attribute name

func (ImageAttribute) Sources

func (a ImageAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*ImageAttribute) Value

func (a *ImageAttribute) Value() media.Media

Value returns the value of the ImageAttribute as media.Media

func (ImageAttribute) Verifiers

func (a ImageAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type ImageSliceAttribute

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

ImageSliceAttribute is a Yoti attribute which returns a slice of images as its value

func NewImageSlice

func NewImageSlice(a *yotiprotoattr.Attribute) (*ImageSliceAttribute, error)

NewImageSlice creates a new ImageSlice attribute

func (ImageSliceAttribute) Anchors

func (a ImageSliceAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (ImageSliceAttribute) ContentType

func (a ImageSliceAttribute) ContentType() string

ContentType gets the attribute's content type description

func (ImageSliceAttribute) ID added in v3.6.0

func (a ImageSliceAttribute) ID() *string

ID gets the attribute ID

func (ImageSliceAttribute) Name

func (a ImageSliceAttribute) Name() string

Name gets the attribute name

func (ImageSliceAttribute) Sources

func (a ImageSliceAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*ImageSliceAttribute) Value

func (a *ImageSliceAttribute) Value() []media.Media

Value returns the value of the ImageSliceAttribute

func (ImageSliceAttribute) Verifiers

func (a ImageSliceAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type IssuanceDetails

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

IssuanceDetails contains information about the attribute(s) issued by a third party

func ParseIssuanceDetails

func ParseIssuanceDetails(thirdPartyAttributeBytes []byte) (*IssuanceDetails, error)

ParseIssuanceDetails takes the Third Party Attribute object and converts it into an IssuanceDetails struct

func (IssuanceDetails) Attributes

func (i IssuanceDetails) Attributes() []Definition

Attributes information about the attributes the third party would like to issue.

func (IssuanceDetails) ExpiryDate

func (i IssuanceDetails) ExpiryDate() *time.Time

ExpiryDate is the timestamp at which the request for the attribute value from third party will expire. Will be nil if not provided.

func (IssuanceDetails) Token

func (i IssuanceDetails) Token() string

Token is the issuance token that can be used to retrieve the user's stored details. These details will be used to issue attributes on behalf of an organisation to that user.

type Item

type Item struct {
	// ContentType is the content of the item.
	ContentType yotiprotoattr.ContentType

	// Value is the underlying data of the item.
	Value interface{}
}

Item is a structure which contains information about an attribute value

type JSONAttribute

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

JSONAttribute is a Yoti attribute which returns an interface as its value

func NewJSON

NewJSON creates a new JSON attribute

Example
proto := yotiprotoattr.Attribute{
	Name:        "exampleJSON",
	Value:       []byte(`{"foo":"bar"}`),
	ContentType: yotiprotoattr.ContentType_JSON,
}
attribute, err := NewJSON(&proto)
if err != nil {
	fmt.Printf("error: %s", err.Error())
	return
}
fmt.Println(attribute.Value())
Output:

map[foo:bar]

func (JSONAttribute) Anchors

func (a JSONAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (JSONAttribute) ContentType

func (a JSONAttribute) ContentType() string

ContentType gets the attribute's content type description

func (JSONAttribute) ID added in v3.6.0

func (a JSONAttribute) ID() *string

ID gets the attribute ID

func (JSONAttribute) Name

func (a JSONAttribute) Name() string

Name gets the attribute name

func (JSONAttribute) Sources

func (a JSONAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*JSONAttribute) Value

func (a *JSONAttribute) Value() map[string]interface{}

Value returns the value of the JSONAttribute as an interface.

func (JSONAttribute) Verifiers

func (a JSONAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type MultiValueAttribute

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

MultiValueAttribute is a Yoti attribute which returns a multi-valued attribute

func NewMultiValue

func NewMultiValue(a *yotiprotoattr.Attribute) (*MultiValueAttribute, error)

NewMultiValue creates a new MultiValue attribute

func (MultiValueAttribute) Anchors

func (a MultiValueAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (MultiValueAttribute) ContentType

func (a MultiValueAttribute) ContentType() string

ContentType gets the attribute's content type description

func (MultiValueAttribute) ID added in v3.6.0

func (a MultiValueAttribute) ID() *string

ID gets the attribute ID

func (MultiValueAttribute) Name

func (a MultiValueAttribute) Name() string

Name gets the attribute name

func (MultiValueAttribute) Sources

func (a MultiValueAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*MultiValueAttribute) Value

func (a *MultiValueAttribute) Value() []*Item

Value returns the value of the MultiValueAttribute as a string

func (MultiValueAttribute) Verifiers

func (a MultiValueAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

type StringAttribute

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

StringAttribute is a Yoti attribute which returns a string as its value

func NewString

NewString creates a new String attribute

func (StringAttribute) Anchors

func (a StringAttribute) Anchors() []*anchor.Anchor

Anchors are the metadata associated with an attribute. They describe how an attribute has been provided to Yoti (SOURCE Anchor) and how it has been verified (VERIFIER Anchor).

func (StringAttribute) ContentType

func (a StringAttribute) ContentType() string

ContentType gets the attribute's content type description

func (StringAttribute) ID added in v3.6.0

func (a StringAttribute) ID() *string

ID gets the attribute ID

func (StringAttribute) Name

func (a StringAttribute) Name() string

Name gets the attribute name

func (StringAttribute) Sources

func (a StringAttribute) Sources() []*anchor.Anchor

Sources returns the anchors which identify how and when an attribute value was acquired.

func (*StringAttribute) Value

func (a *StringAttribute) Value() string

Value returns the value of the StringAttribute as a string

func (StringAttribute) Verifiers

func (a StringAttribute) Verifiers() []*anchor.Anchor

Verifiers returns the anchors which identify how and when an attribute value was verified by another provider.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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