display

package
v0.0.0-...-ad7f959 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package display contains functionality that can be used to resolve display values per the OpenID4CI spec.

Package display contains functionality that can be used to resolve display values per the OpenID4CI spec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

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

Attachment represents display data for a credential. Display data for specific claims (e.g. first name, date of birth, etc.) are in the CredentialSubject objects.

func (*Attachment) Description

func (c *Attachment) Description() string

Description returns the description of the credential attachment.

func (*Attachment) Hash

func (c *Attachment) Hash() string

Hash returns the hash of the attachment data.

func (*Attachment) HashAlg

func (c *Attachment) HashAlg() string

HashAlg returns the hash algorithm used to hash the attachment data.

func (*Attachment) ID

func (c *Attachment) ID() string

ID returns the attachment ID.

func (*Attachment) MimeType

func (c *Attachment) MimeType() string

MimeType returns mime-type of the credential attachment.

func (*Attachment) Type

func (c *Attachment) Type() string

Type returns the attachment Type. This could be "EmbeddedAttachment", "RemoteAttachment" or "AttachmentEvidence". For EmbeddedAttachment, the uri will be a data URI. Hash and HashAlg will provide the hash value of the data along with Hash algorithm used to generate the hash. For RemoteAttachment, the uri will be a remote HTTP URL. Hash and HashAlg will provide the hash value of the data along with Hash algorithm used to generate the hash. Consumer of this API need to validate the hash value against the hash of the data object retrieved from the remote url For AttachmentEvidence, the uri will be empty. But the hash and hashAlg will provide the hash value of the data along with Hash algorithm used to generate the hash. Consumer of this API need to validate the hash value against the hash of the data object retrieved from the out of band.

func (*Attachment) URI

func (c *Attachment) URI() string

URI returns URI of the attachment. This could be embedded data or a link to external data.

type Claim

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

Claim represents display data for a specific claim.

func (*Claim) Attachment

func (c *Claim) Attachment() *Attachment

Attachment returns the attachment data. Check this field if the claim type is "attachment", instead of value field.

func (*Claim) HasOrder

func (c *Claim) HasOrder() bool

HasOrder returns whether this Claim has a specified order in it.

func (*Claim) IsMasked

func (c *Claim) IsMasked() bool

IsMasked indicates whether this claim's value is masked. If this method returns true, then the Value method will return the masked value while the RawValue method will return the unmasked version.

func (*Claim) Label

func (c *Claim) Label() string

Label returns the display label for this claim. For example, if the UI were to display "Given Name: Alice", then the Label would be "Given Name".

func (*Claim) Locale

func (c *Claim) Locale() string

Locale returns the locale corresponding to this claim's display data. The locale is determined during the ResolveDisplay call based on the preferred locale passed in and what localizations were provided in the issuer's metadata.

func (*Claim) Order

func (c *Claim) Order() (int, error)

Order returns the display order for this claim. HasOrder should be called first to ensure this claim has a specified order before calling this method. This method returns an error if the claim has no specified order.

func (*Claim) Pattern

func (c *Claim) Pattern() string

Pattern returns the pattern information for this claim.

func (*Claim) RawID

func (c *Claim) RawID() string

RawID returns the raw field name (key) from the VC associated with this claim. It's not localized or formatted for display.

func (*Claim) RawValue

func (c *Claim) RawValue() string

RawValue returns the raw display value for this claim without any formatting. For example, if this claim is masked, this method will return the unmasked version. If no special formatting was applied to the display value, then this method will be equivalent to calling Value.

func (*Claim) Value

func (c *Claim) Value() string

Value returns the display value for this claim. For example, if the UI were to display "Given Name: Alice", then the Value would be "Alice". If no special formatting was applied to the display value, then this method will be equivalent to calling RawValue.

func (*Claim) ValueType

func (c *Claim) ValueType() string

ValueType returns the display value type for this claim. For example: "string", "number", "image", "attachment" etc. For type=attachment, ignore the RawValue() and Value(), instead use Attachment() method.

type Credential

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

Credential represents display data for a credential.

func (*Credential) LocalizedOverviewAtIndex

func (d *Credential) LocalizedOverviewAtIndex(index int) *Overview

LocalizedOverviewAtIndex returns the number of different locales supported for the issuer displays. If the index passed in is out of bounds, then nil is returned.

func (*Credential) LocalizedOverviewsLength

func (d *Credential) LocalizedOverviewsLength() int

LocalizedOverviewsLength returns the number of different locales supported for the credential displays.

func (*Credential) SubjectAtIndex

func (c *Credential) SubjectAtIndex(index int) *Subject

SubjectAtIndex returns the credential subject display object at the given index. If the index passed in is out of bounds, then nil is returned.

func (*Credential) SubjectsLength

func (c *Credential) SubjectsLength() int

SubjectsLength returns the number of credential subject displays contained within this Credential object.

type CredentialDisplay

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

CredentialDisplay represents display data for a credential. Display data for specific claims (e.g. first name, date of birth, etc.) are in the CredentialSubject objects.

func ParseCredentialDisplay

func ParseCredentialDisplay(credentialDisplay string) (*CredentialDisplay, error)

ParseCredentialDisplay parses the given serialized credential display data and returns a CredentialDisplay object.

func (*CredentialDisplay) ClaimAtIndex

func (c *CredentialDisplay) ClaimAtIndex(index int) *Claim

ClaimAtIndex returns the claim display object at the given index. If the index passed in is out of bounds, then nil is returned.

func (*CredentialDisplay) ClaimsLength

func (c *CredentialDisplay) ClaimsLength() int

ClaimsLength returns the number of claims displays contained within this CredentialDisplay object.

func (*CredentialDisplay) Overview

func (c *CredentialDisplay) Overview() *CredentialOverview

Overview returns the credential overview display object.

func (*CredentialDisplay) Serialize

func (c *CredentialDisplay) Serialize() (string, error)

Serialize serializes this CredentialDisplay object into JSON.

type CredentialOverview

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

CredentialOverview represents display data for a credential as a whole.

func (*CredentialOverview) BackgroundColor

func (c *CredentialOverview) BackgroundColor() string

BackgroundColor returns the background color that should be used when displaying this credential.

func (*CredentialOverview) Locale

func (c *CredentialOverview) Locale() string

Locale returns the locale corresponding to this credential overview's display data. The locale is determined during the ResolveDisplay call based on the preferred locale passed in and what localizations were provided in the issuer's metadata.

func (c *CredentialOverview) Logo() *Logo

Logo returns display logo data for the credential.

func (*CredentialOverview) Name

func (c *CredentialOverview) Name() string

Name returns the display name for the credential.

func (*CredentialOverview) TextColor

func (c *CredentialOverview) TextColor() string

TextColor returns the text color that should be used when displaying this credential.

type Data

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

Data represents display information for some issued credentials based on an issuer's metadata.

func ParseData

func ParseData(displayData string) (*Data, error)

ParseData parses the given serialized display data and returns a display Data object.

func Resolve

func Resolve(vcs *verifiable.CredentialsArray, issuerURI string, opts *Opts) (*Data, error)

Resolve resolves display information for issued credentials based on an issuer's metadata, which is fetched using the issuer's (base) URI. The CredentialDisplays in the returned Data object correspond to the VCs passed in and are in the same order. This method requires one or more VCs and the issuer's base URI. Deprecated: Use ResolveCredential function instead, which would give data for all locales. The consumer of the SDK can run logic to display exact locale data to the user.

func ResolveCredentialOffer

func ResolveCredentialOffer(
	issuerMetadata *openid4ci.IssuerMetadata, offeredTypes *api.StringArrayArray, preferredLocale string,
) *Data

ResolveCredentialOffer resolves display information for some offered credentials based on an issuer's metadata. The CredentialDisplays in the returned ResolvedDisplayData object correspond to the offered credential types passed in and are in the same order.

func (*Data) CredentialDisplayAtIndex

func (d *Data) CredentialDisplayAtIndex(index int) *CredentialDisplay

CredentialDisplayAtIndex returns the credential display object at the given index. If the index passed in is out of bounds, then nil is returned.

func (*Data) CredentialDisplaysLength

func (d *Data) CredentialDisplaysLength() int

CredentialDisplaysLength returns the number of credential displays contained within this display Data object.

func (*Data) IssuerDisplay

func (d *Data) IssuerDisplay() *IssuerDisplay

IssuerDisplay returns the issuer display object.

func (*Data) Serialize

func (d *Data) Serialize() (string, error)

Serialize serializes this display Data object into JSON.

type Issuer

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

Issuer represents display information about the issuer of some credential(s).

func (*Issuer) BackgroundColor

func (d *Issuer) BackgroundColor() string

BackgroundColor returns this LocalizedIssuerDisplay's background color.

func (*Issuer) Locale

func (d *Issuer) Locale() string

Locale returns the locale corresponding to this issuer's display name. The locale is determined during the ResolveDisplay call based on the preferred locale passed in and what localizations were provided in the issuer's metadata.

func (d *Issuer) Logo() *Logo

Logo returns this IssuerDisplay's logo. If it has no logo, then nil/null is returned instead.

func (*Issuer) Name

func (d *Issuer) Name() string

Name returns the issuer's display name.

func (*Issuer) Serialize

func (d *Issuer) Serialize() (string, error)

Serialize serializes this IssuerDisplay object into JSON.

func (*Issuer) TextColor

func (d *Issuer) TextColor() string

TextColor returns this IssuerDisplay's text color.

func (*Issuer) URL

func (d *Issuer) URL() string

URL returns this IssuerDisplay's URL.

type IssuerDisplay

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

IssuerDisplay represents display information about the issuer of some credential(s).

func ParseIssuerDisplay

func ParseIssuerDisplay(issuerDisplay string) (*IssuerDisplay, error)

ParseIssuerDisplay parses the given serialized issuer display data and returns an IssuerDisplay object.

func (*IssuerDisplay) BackgroundColor

func (d *IssuerDisplay) BackgroundColor() string

BackgroundColor returns this LocalizedIssuerDisplay's background color.

func (*IssuerDisplay) Locale

func (d *IssuerDisplay) Locale() string

Locale returns the locale corresponding to this issuer's display name. The locale is determined during the ResolveDisplay call based on the preferred locale passed in and what localizations were provided in the issuer's metadata.

func (d *IssuerDisplay) Logo() *Logo

Logo returns this IssuerDisplay's logo. If it has no logo, then nil/null is returned instead.

func (*IssuerDisplay) Name

func (d *IssuerDisplay) Name() string

Name returns the issuer's display name.

func (*IssuerDisplay) Serialize

func (d *IssuerDisplay) Serialize() (string, error)

Serialize serializes this IssuerDisplay object into JSON.

func (*IssuerDisplay) TextColor

func (d *IssuerDisplay) TextColor() string

TextColor returns this IssuerDisplay's text color.

func (*IssuerDisplay) URL

func (d *IssuerDisplay) URL() string

URL returns this IssuerDisplay's URL.

type Label

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

Label represents localized name and locale..

func (*Label) Locale

func (c *Label) Locale() string

Locale locale value.

func (*Label) Name

func (c *Label) Name() string

Name in a locale.

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

Logo represents display information for a logo.

func (*Logo) AltText

func (l *Logo) AltText() string

AltText returns alt text for this logo.

func (*Logo) URL

func (l *Logo) URL() string

URL returns the URL where this logo's image can be fetched.

type Opts

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

Opts contains all optional arguments that can be passed into the Resolve function.

func NewOpts

func NewOpts() *Opts

NewOpts returns a new Opts object.

func (*Opts) AddHeaders

func (o *Opts) AddHeaders(headers *api.Headers) *Opts

AddHeaders adds the given HTTP headers to all REST calls made to the issuer during display resolution.

func (*Opts) DisableHTTPClientTLSVerify

func (o *Opts) DisableHTTPClientTLSVerify() *Opts

DisableHTTPClientTLSVerify disables TLS verification. Should be used for testing purposes only.

func (*Opts) SetDIDResolver

func (o *Opts) SetDIDResolver(didResolver api.DIDResolver) *Opts

SetDIDResolver sets a DID resolver to be used. If the issuer metadata is signed, then a DID resolver must be provided so that the issuer metadata's signature can be verified.

func (*Opts) SetHTTPTimeoutNanoseconds

func (o *Opts) SetHTTPTimeoutNanoseconds(timeout int64) *Opts

SetHTTPTimeoutNanoseconds sets the timeout (in nanoseconds) for HTTP calls. Passing in 0 will disable timeouts.

func (*Opts) SetMaskingString

func (o *Opts) SetMaskingString(maskingString string) *Opts

SetMaskingString sets the string to be used when creating masked values for display. The substitution is done on a character-by-character basis, whereby each individual character to be masked will be replaced by the entire string. See the examples below to better understand exactly how the substitution works.

(Note that any quote characters in the examples below are only there for readability reasons - they're not actually part of the values.)

Scenario: The unmasked display value is 12345, and the issuer's metadata specifies that the first 3 characters are to be masked. The most common use-case is to substitute every masked character with a single character. This is achieved by specifying just a single character in the maskingString. Here's what the masked value would look like with different maskingString choices:

maskingString: "•" --> •••45 maskingString: "*" --> ***45

It's also possible to specify multiple characters in the maskingString, or even an empty string if so desired. Here's what the masked value would like in such cases:

maskingString: "???" --> ?????????45 maskingString: "" --> 45

If this option isn't used, then by default "•" characters (without the quotes) will be used for masking.

func (*Opts) SetMetricsLogger

func (o *Opts) SetMetricsLogger(metricsLogger api.MetricsLogger) *Opts

SetMetricsLogger sets a metrics logger to use.

func (*Opts) SetPreferredLocale

func (o *Opts) SetPreferredLocale(preferredLocale string) *Opts

SetPreferredLocale sets the preferred locale to use while resolving VC display data. If the preferred locale is not available (or no preferred locale is specified), then the first locale specified by the issuer's metadata will be used during resolution. The actual locales used for various pieces of display information are available in the Data object.

func (*Opts) SkipNonClaimData

func (o *Opts) SkipNonClaimData() *Opts

SkipNonClaimData skips the non-claims related data like issue and expiry date.

type Overview

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

Overview represents display data for a credential as a whole.

func (*Overview) BackgroundColor

func (c *Overview) BackgroundColor() string

BackgroundColor returns the background color that should be used when displaying this credential.

func (*Overview) Locale

func (c *Overview) Locale() string

Locale returns the locale corresponding to this credential overview's display data. The locale is determined during the ResolveDisplay call based on the preferred locale passed in and what localizations were provided in the issuer's metadata.

func (c *Overview) Logo() *Logo

Logo returns display logo data for the credential.

func (*Overview) Name

func (c *Overview) Name() string

Name returns the display name for the credential.

func (*Overview) TextColor

func (c *Overview) TextColor() string

TextColor returns the text color that should be used when displaying this credential.

type Resolved

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

Resolved represents display information for all locales for the issued credentials based on an issuer's metadata.

func ParseResolvedData

func ParseResolvedData(displayData string) (*Resolved, error)

ParseResolvedData parses the given serialized display data and returns a display Data object.

func ResolveCredential

func ResolveCredential(credentialsArray *verifiable.CredentialsArray, issuerURI string, opts *Opts) (*Resolved, error)

func ResolveCredentialV2

func ResolveCredentialV2(credentialsArray *verifiable.CredentialsArrayV2, issuerURI string, opts *Opts) (*Resolved, error)

func (*Resolved) CredentialAtIndex

func (d *Resolved) CredentialAtIndex(index int) *Credential

CredentialAtIndex returns the credential display object at the given index. If the index passed in is out of bounds, then nil is returned.

func (*Resolved) CredentialsLength

func (d *Resolved) CredentialsLength() int

CredentialsLength returns the number of credential displays contained within this display Data object.

func (*Resolved) LocalizedIssuerAtIndex

func (d *Resolved) LocalizedIssuerAtIndex(index int) *Issuer

LocalizedIssuerAtIndex returns the issuer display object at the given index. If the index passed in is out of bounds, then nil is returned.

func (*Resolved) LocalizedIssuersLength

func (d *Resolved) LocalizedIssuersLength() int

LocalizedIssuersLength returns the number of different locales supported for the issuer displays.

func (*Resolved) Serialize

func (d *Resolved) Serialize() (string, error)

Serialize serializes this display Data object into JSON.

type Subject

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

Subject represents display data for a specific credential subject including all locales for the label.

func (*Subject) Attachment

func (c *Subject) Attachment() *Attachment

Attachment returns the attachment data. Check this field if the claim type is "attachment", instead of value field.

func (*Subject) HasOrder

func (c *Subject) HasOrder() bool

HasOrder returns whether this Claim has a specified order in it.

func (*Subject) IsMasked

func (c *Subject) IsMasked() bool

IsMasked indicates whether this claim's value is masked. If this method returns true, then the Value method will return the masked value while the RawValue method will return the unmasked version.

func (*Subject) LocalizedLabelAtIndex

func (c *Subject) LocalizedLabelAtIndex(index int) *Label

LocalizedLabelAtIndex returns the label at the given index. If the index passed in is out of bounds, then nil is returned.

func (*Subject) LocalizedLabelsLength

func (c *Subject) LocalizedLabelsLength() int

LocalizedLabelsLength returns the number of different locales supported for the credential subject.

func (*Subject) Order

func (c *Subject) Order() (int, error)

Order returns the display order for this claim. HasOrder should be called first to ensure this claim has a specified order before calling this method. This method returns an error if the claim has no specified order.

func (*Subject) Pattern

func (c *Subject) Pattern() string

Pattern returns the pattern information for this claim.

func (*Subject) RawID

func (c *Subject) RawID() string

RawID returns the raw field name (key) from the VC associated with this claim. It's not localized or formatted for display.

func (*Subject) RawValue

func (c *Subject) RawValue() string

RawValue returns the raw display value for this claim without any formatting. For example, if this claim is masked, this method will return the unmasked version. If no special formatting was applied to the display value, then this method will be equivalent to calling Value.

func (*Subject) Value

func (c *Subject) Value() string

Value returns the display value for this claim. For example, if the UI were to display "Given Name: Alice", then the Value would be "Alice". If no special formatting was applied to the display value, then this method will be equivalent to calling RawValue.

func (*Subject) ValueType

func (c *Subject) ValueType() string

ValueType returns the display value type for this claim. For example: "string", "number", "image", "attachment" etc. For type=attachment, ignore the RawValue() and Value(), instead use Attachment() method.

Jump to

Keyboard shortcuts

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