Documentation
¶
Index ¶
Constants ¶
const ( VerifiableCredentialsLinkedDataContext string = "https://www.w3.org/ns/credentials/v2" VerifiableCredentialsUndefinedTermsLinkedDataContext string = "https://www.w3.org/ns/credentials/undefined-terms/v2" VerifiableCredentialType string = "VerifiableCredential" VerifiablePresentationType string = "VerifiablePresentation" EnvelopedVerifiableCredentialType string = "EnvelopedVerifiableCredential" EnvelopedVerifiablePresentationType string = "EnvelopedVerifiablePresentation" VerifiableCredentialJSONSchemaType string = "JsonSchema" VerifiableCredentialIDProperty string = "id" VCContentType string = "vc" VPContentType string = "vp" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IssuerHolder ¶
type IssuerHolder struct {
// contains filtered or unexported fields
}
IssuerHolder represents the issuer of a Verifiable Credential or holder of a Verifiable Presentation, which can be either a URL string or an object containing an ID property
func NewIssuerHolderFromObject ¶
func NewIssuerHolderFromObject(id string, object map[string]any) *IssuerHolder
NewIssuerHolderFromObject creates an IssuerHolder from an object with an `id` field
func NewIssuerHolderFromString ¶
func NewIssuerHolderFromString(id string) *IssuerHolder
NewIssuerHolderFromString creates an IssuerHolder from a string (URL or ID)
func (*IssuerHolder) Get ¶
func (i *IssuerHolder) Get(property string) any
Get returns the value of a property in the issuer/holder object, or nil if the issuer/holder is a string or the property doesn't exist
func (*IssuerHolder) IsEmpty ¶
func (i *IssuerHolder) IsEmpty() bool
IsEmpty returns true if the issuer is empty
func (*IssuerHolder) IsObject ¶
func (i *IssuerHolder) IsObject() bool
IsObject returns true if the issuer is an object, false if it's a string
func (*IssuerHolder) MarshalJSON ¶
func (i *IssuerHolder) MarshalJSON() ([]byte, error)
MarshalJSON implements custom marshaling for IssuerHolder
func (*IssuerHolder) UnmarshalJSON ¶
func (i *IssuerHolder) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom unmarshaling for IssuerHolder
type VerifiableCredential ¶
type VerifiableCredential struct { Context util.SingleOrArray[string] `json:"@context,omitempty" validate:"required"` Type util.SingleOrArray[string] `json:"type,omitempty" validate:"required"` ID string `json:"id,omitempty"` // either a URI or an object containing an `id` property. Issuer *IssuerHolder `json:"issuer,omitempty" validate:"required"` // https://www.w3.org/TR/xmlschema11-2/#dateTimes ValidFrom string `json:"validFrom,omitempty" validate:"required"` ValidUntil string `json:"validUntil,omitempty"` // This is where the subject's ID *may* be present CredentialSubject Subject `json:"credentialSubject,omitempty"` CredentialSchema util.SingleOrArray[Schema] `json:"credentialSchema,omitempty"` CredentialStatus util.SingleOrArray[any] `json:"credentialStatus,omitempty"` TermsOfUse util.SingleOrArray[any] `json:"termsOfUse,omitempty"` Evidence util.SingleOrArray[any] `json:"evidence,omitempty"` }
VerifiableCredential is the verifiable credential model outlined in the vc-data-model spec https://www.w3.org/TR/vc-data-model-2.0/#verifiable-credentials
func (*VerifiableCredential) IsEmpty ¶
func (vc *VerifiableCredential) IsEmpty() bool
func (*VerifiableCredential) IsValid ¶
func (vc *VerifiableCredential) IsValid() error
func (*VerifiableCredential) IssuerID ¶
func (vc *VerifiableCredential) IssuerID() string
type VerifiablePresentation ¶
type VerifiablePresentation struct { Context util.SingleOrArray[string] `json:"@context,omitempty" validate:"required"` Type util.SingleOrArray[string] `json:"type,omitempty" validate:"required"` ID string `json:"id,omitempty"` Holder *IssuerHolder `json:"holder,omitempty"` VerifiableCredential []VerifiableCredential `json:"verifiableCredential,omitempty"` }
VerifiablePresentation https://www.w3.org/TR/vc-data-model-2.0/#verifiable-presentations
func (*VerifiablePresentation) IsEmpty ¶
func (vp *VerifiablePresentation) IsEmpty() bool
func (*VerifiablePresentation) IsValid ¶
func (vp *VerifiablePresentation) IsValid() error