schema

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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

func IsSupportedJSONSchemaVersion(version string) bool

IsSupportedJSONSchemaVersion returns true if the given version is supported

func IsSupportedVCJSONSchemaType

func IsSupportedVCJSONSchemaType(t string) bool

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

type JSONSchema map[string]any

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

type RemoteAccess struct {
	*http.Client
	// contains filtered or unexported fields
}

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

type VCJSONSchema map[string]any

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

Jump to

Keyboard shortcuts

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