credentialschema

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package credentialschema contains a function that can be used to resolve display values per the OpenID4CI spec. This implementation follows the 27 October 2022 revision of https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#section-11.2

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialDisplay

type CredentialDisplay struct {
	Overview *issuer.CredentialDisplay `json:"overview,omitempty"`
	Claims   []ResolvedClaim           `json:"claims,omitempty"`
}

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

type ResolveOpt

type ResolveOpt func(opts *resolveOpts)

ResolveOpt represents an option for the Resolve function.

func WithCredentialReader

func WithCredentialReader(credentialReader credentialReader, ids []string) ResolveOpt

WithCredentialReader is an option allowing a caller to specify the VCs they want to have resolved by providing their IDs along with a CredentialReader.

func WithCredentials

func WithCredentials(vcs []*verifiable.Credential) ResolveOpt

WithCredentials is an option allowing a caller to directly pass in the VCs that they want to have resolved.

func WithIssuerMetadata

func WithIssuerMetadata(metadata *issuer.Metadata) ResolveOpt

WithIssuerMetadata is an option allowing a caller to directly pass in the issuer's metadata to use for resolving VCs.

func WithIssuerURI

func WithIssuerURI(uri string) ResolveOpt

WithIssuerURI is an option allowing a caller to specify an issuer URI that will be used to fetch metadata. Using this option will cause the Resolve function to fetch an issuer's metadata by doing a lookup on its OpenID configuration endpoint. The issuer URI is expected to be the base URL for the issuer.

func WithPreferredLocale

func WithPreferredLocale(locale string) ResolveOpt

WithPreferredLocale is an option specifying the caller's preferred locale to look for when resolving VCs. If not specified, or the user's preferred locale is not available, 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 ResolvedDisplayData object.

type ResolvedClaim

type ResolvedClaim struct {
	Label  string `json:"label,omitempty"`
	Value  string `json:"value,omitempty"`
	Locale string `json:"locale,omitempty"`
}

ResolvedClaim represents display data for a specific claim.

type ResolvedCredentialIssuerDisplay

type ResolvedCredentialIssuerDisplay struct {
	Name   string `json:"name,omitempty"`
	Locale string `json:"locale,omitempty"`
}

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

type ResolvedDisplayData

type ResolvedDisplayData struct {
	IssuerDisplay      *ResolvedCredentialIssuerDisplay `json:"issuer_display,omitempty"`
	CredentialDisplays []CredentialDisplay              `json:"credential_displays,omitempty"`
}

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

func Resolve

func Resolve(opts ...ResolveOpt) (*ResolvedDisplayData, error)

Resolve resolves display information for some issued credentials based on an issuer's metadata. The CredentialDisplays in the returned ResolvedDisplayData object correspond to the VCs passed in and are in the same order. This method requires one VC source and one issuer metadata source. See opts.go for more information.

Jump to

Keyboard shortcuts

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