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 ¶
- type Attachment
- type Claim
- func (c *Claim) Attachment() *Attachment
- func (c *Claim) HasOrder() bool
- func (c *Claim) IsMasked() bool
- func (c *Claim) Label() string
- func (c *Claim) Locale() string
- func (c *Claim) Order() (int, error)
- func (c *Claim) Pattern() string
- func (c *Claim) RawID() string
- func (c *Claim) RawValue() string
- func (c *Claim) Value() string
- func (c *Claim) ValueType() string
- type Credential
- type CredentialDisplay
- type CredentialOverview
- type Data
- type Issuer
- type IssuerDisplay
- type Label
- type Logo
- type Opts
- func (o *Opts) AddHeaders(headers *api.Headers) *Opts
- func (o *Opts) DisableHTTPClientTLSVerify() *Opts
- func (o *Opts) SetDIDResolver(didResolver api.DIDResolver) *Opts
- func (o *Opts) SetHTTPTimeoutNanoseconds(timeout int64) *Opts
- func (o *Opts) SetMaskingString(maskingString string) *Opts
- func (o *Opts) SetMetricsLogger(metricsLogger api.MetricsLogger) *Opts
- func (o *Opts) SetPreferredLocale(preferredLocale string) *Opts
- func (o *Opts) SkipNonClaimData() *Opts
- type Overview
- type Resolved
- func ParseResolvedData(displayData string) (*Resolved, error)
- func ResolveCredential(credentialsArray *verifiable.CredentialsArray, issuerURI string, opts *Opts) (*Resolved, error)
- func ResolveCredentialV2(credentialsArray *verifiable.CredentialsArrayV2, issuerURI string, opts *Opts) (*Resolved, error)
- type Subject
- func (c *Subject) Attachment() *Attachment
- func (c *Subject) HasOrder() bool
- func (c *Subject) IsMasked() bool
- func (c *Subject) LocalizedLabelAtIndex(index int) *Label
- func (c *Subject) LocalizedLabelsLength() int
- func (c *Subject) Order() (int, error)
- func (c *Subject) Pattern() string
- func (c *Subject) RawID() string
- func (c *Subject) RawValue() string
- func (c *Subject) Value() string
- func (c *Subject) ValueType() string
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) 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) IsMasked ¶
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 ¶
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 ¶
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 ¶
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) RawID ¶
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 ¶
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.
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 (*CredentialOverview) Logo ¶
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 ¶
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 ¶
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.
type Issuer ¶
type Issuer struct {
// contains filtered or unexported fields
}
Issuer represents display information about the issuer of some credential(s).
func (*Issuer) BackgroundColor ¶
BackgroundColor returns this LocalizedIssuerDisplay's background color.
func (*Issuer) Locale ¶
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 (*Issuer) Logo ¶
Logo returns this IssuerDisplay's logo. If it has no logo, then nil/null is returned instead.
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 (*IssuerDisplay) Logo ¶
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..
type Logo ¶
type Logo struct {
// contains filtered or unexported fields
}
Logo represents display information for a logo.
type Opts ¶
type Opts struct {
// contains filtered or unexported fields
}
Opts contains all optional arguments that can be passed into the Resolve function.
func (*Opts) AddHeaders ¶
AddHeaders adds the given HTTP headers to all REST calls made to the issuer during display resolution.
func (*Opts) DisableHTTPClientTLSVerify ¶
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 ¶
SetHTTPTimeoutNanoseconds sets the timeout (in nanoseconds) for HTTP calls. Passing in 0 will disable timeouts.
func (*Opts) SetMaskingString ¶
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 ¶
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 ¶
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 ¶
BackgroundColor returns the background color that should be used when displaying this credential.
func (*Overview) Locale ¶
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.
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 ¶
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 ¶
CredentialsLength returns the number of credential displays contained within this display Data object.
func (*Resolved) LocalizedIssuerAtIndex ¶
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 ¶
LocalizedIssuersLength returns the number of different locales supported for the issuer displays.
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) IsMasked ¶
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 ¶
LocalizedLabelAtIndex returns the label at the given index. If the index passed in is out of bounds, then nil is returned.
func (*Subject) LocalizedLabelsLength ¶
LocalizedLabelsLength returns the number of different locales supported for the credential subject.
func (*Subject) Order ¶
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) RawID ¶
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 ¶
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.