Documentation ¶
Index ¶
- Constants
- func GetCredentialSchemaFromCredential(access VCJSONSchemaAccess, cred credential.VerifiableCredential) (VCJSONSchema, VCJSONSchemaType, error)
- func IsCredentialValidForJSONSchema(cred credential.VerifiableCredential, vcs VCJSONSchema, t VCJSONSchemaType) error
- func IsSupportedJSONSchemaVersion(version string) bool
- func IsSupportedVCJSONSchemaType(t string) bool
- func ValidateCredentialAgainstSchema(access VCJSONSchemaAccess, cred credential.VerifiableCredential) error
- type JSONSchema
- type JSONSchemaVersion
- type RemoteAccess
- type VCJSONSchema
- type VCJSONSchemaAccess
- type VCJSONSchemaType
Constants ¶
const ( // JSONSchemaCredentialType https://www.w3.org/TR/vc-json-schema/#jsonschemacredential JSONSchemaCredentialType VCJSONSchemaType = "JsonSchemaCredential" // JSONSchemaType https://www.w3.org/TR/vc-json-schema/#jsonschema JSONSchemaType VCJSONSchemaType = "JsonSchema" TypeProperty string = "type" JSONSchemaCredentialSchemaID = "https://www.w3.org/2022/credentials/v2/json-schema-credential-schema.json" JSONSchemaCredentialDigestSRI = "sha384-S57yQDg1MTzF56Oi9DbSQ14u7jBy0RDdx0YbeV7shwhCS88G8SCXeFq82PafhCrW" Draft202012 JSONSchemaVersion = "https://json-schema.org/draft/2020-12/schema" Draft201909 JSONSchemaVersion = "https://json-schema.org/draft/2019-09/schema" Draft7 JSONSchemaVersion = "https://json-schema.org/draft-07/schema#" JSONSchemaIDProperty = "$id" JSONSchemaAdditionalIDProperty = "id" JSONSchemaSchemaProperty = "$schema" JSONSchemaNameProperty = "name" JSONSchemaDescriptionProperty = "description" )
Variables ¶
This section is empty.
Functions ¶
func GetCredentialSchemaFromCredential ¶
func GetCredentialSchemaFromCredential(access VCJSONSchemaAccess, cred credential.VerifiableCredential) (VCJSONSchema, VCJSONSchemaType, error)
GetCredentialSchemaFromCredential returns the credential schema and type for a given credential given a credential schema access, which is used to retrieve the schema
func IsCredentialValidForJSONSchema ¶
func IsCredentialValidForJSONSchema(cred credential.VerifiableCredential, vcs VCJSONSchema, t VCJSONSchemaType) error
IsCredentialValidForJSONSchema validates a credential against a schema, returning an error if it is not valid
func IsSupportedJSONSchemaVersion ¶
IsSupportedJSONSchemaVersion returns true if the given version is supported
func IsSupportedVCJSONSchemaType ¶
IsSupportedVCJSONSchemaType returns true if the given type is supported
func ValidateCredentialAgainstSchema ¶
func ValidateCredentialAgainstSchema(access VCJSONSchemaAccess, cred credential.VerifiableCredential) error
ValidateCredentialAgainstSchema validates a credential against a schema, returning an error if it is not valid The schema is retrieved from the given VCJSONSchemaAccess using the credential's credential schema ID
Types ¶
type JSONSchema ¶
func (JSONSchema) Description ¶
func (s JSONSchema) Description() string
func (JSONSchema) GetProperty ¶
func (s JSONSchema) GetProperty(propertyName string) (any, error)
GetProperty returns the value of a property in the schema
func (JSONSchema) ID ¶
func (s JSONSchema) ID() string
func (JSONSchema) Name ¶
func (s JSONSchema) Name() string
func (JSONSchema) Schema ¶
func (s JSONSchema) Schema() string
func (JSONSchema) String ¶
func (s JSONSchema) String() string
type JSONSchemaVersion ¶
type JSONSchemaVersion string
func GetSupportedJSONSchemaVersions ¶
func GetSupportedJSONSchemaVersions() []JSONSchemaVersion
GetSupportedJSONSchemaVersions returns the supported JSON Schema versions
func (JSONSchemaVersion) String ¶
func (s JSONSchemaVersion) String() string
type RemoteAccess ¶
RemoteAccess is used to retrieve a vc json schema from a remote location
func NewRemoteAccess ¶
func NewRemoteAccess(baseURL *string) *RemoteAccess
NewRemoteAccess returns a new instance of RemoteAccess, accepting an optional baseURL to prepend to any schema id that is being fetched.
func (*RemoteAccess) GetVCJSONSchema ¶
func (ra *RemoteAccess) GetVCJSONSchema(ctx context.Context, t VCJSONSchemaType, id string) (VCJSONSchema, error)
GetVCJSONSchema returns a vc json schema for the given ID and its type as a json string by making a GET request to the given ID. If a baseURL was provided to NewRemoteAccess, it will be prepended to the ID.
type VCJSONSchema ¶
func (VCJSONSchema) String ¶
func (s VCJSONSchema) String() string
type VCJSONSchemaAccess ¶
type VCJSONSchemaAccess interface { // GetVCJSONSchema returns a vc json schema for the given ID as a json string according to the given VCJSONSchemaType GetVCJSONSchema(ctx context.Context, t VCJSONSchemaType, id string) (VCJSONSchema, error) }
type VCJSONSchemaType ¶
type VCJSONSchemaType string
func GetSupportedVCJSONSchemaTypes ¶
func GetSupportedVCJSONSchemaTypes() []VCJSONSchemaType
GetSupportedVCJSONSchemaTypes returns the supported VC JSON Schema types
func (VCJSONSchemaType) String ¶
func (s VCJSONSchemaType) String() string