Documentation
¶
Index ¶
- Constants
- Variables
- func AddContext(context interface{}, newContext ssi.URI) []interface{}
- func AllFieldsDefined(DocumentLoader ld.DocumentLoader, inputJSON []byte) error
- func DefaultAllowList() []string
- func FlagSet() *pflag.FlagSet
- func JWS2020ContextV1URI() ssi.URI
- func NewContextLoader(allowUnlistedExternalCalls bool, contexts ContextsConfig) (ld.DocumentLoader, error)
- func NewEmbeddedFSDocumentLoader(fs embed.FS, nextLoader ld.DocumentLoader) ld.DocumentLoader
- func NewFilteredLoader(allowedURLs []string, nextLoader ld.DocumentLoader) ld.DocumentLoader
- func NewMappedDocumentLoader(mapping map[string]string, nextLoader ld.DocumentLoader) ld.DocumentLoader
- func TestVC() vc.VerifiableCredential
- type BoolScalar
- type Config
- type ContextsConfig
- type Document
- type Float64Scalar
- type JSONLD
- type LDUtil
- type Path
- type Reader
- type Scalar
- type StringScalar
Constants ¶
const JSONLDExample = `` /* 855-byte string literal not displayed */
JSONLDExample is a JSON-LD document example with a custom nested context covering all different supported term types.
const JSONLdBase = ""
JSONLdBase is the base URL used for IRIs that are unknown when expanding a JSON-LD document.
const Jws2020Context = "https://w3c-ccg.github.io/lds-jws2020/contexts/lds-jws2020-v1.json"
Jws2020Context contains the JsonWebToken2020 Proof type context
const SchemaOrgContext = "https://schema.org"
SchemaOrgContext contains the schema.org context url
const TestCredential = `` /* 558-byte string literal not displayed */
TestCredential contains a valid credential of the Humancredential type
const TestOrganizationCredential = `` /* 798-byte string literal not displayed */
TestOrganizationCredential is an example of a NutsOrganizationCredential without Proof
const W3cStatusList2021Context = "https://w3id.org/vc/status-list/2021/v1"
W3cStatusList2021Context contains the StatusList2021 related context
const W3cVcContext = "https://www.w3.org/2018/credentials/v1"
W3cVcContext contains the w3c VerifiableCredential type context
Variables ¶
var ( // OrganizationNamePath contains the JSON-LD search path for finding an organization name OrganizationNamePath = NewPath("https://www.w3.org/2018/credentials#credentialSubject", "http://schema.org/organization", "http://schema.org/legalname") // OrganizationCityPath contains the JSON-LD search path for finding an organization city OrganizationCityPath = NewPath("https://www.w3.org/2018/credentials#credentialSubject", "http://schema.org/organization", "http://schema.org/city") // CredentialSubjectPath contains the JSON-LD search path for the credential subject ID CredentialSubjectPath = NewPath("https://www.w3.org/2018/credentials#credentialSubject") // CredentialIssuerPath contains the JSON-LD search path for the credential issuer CredentialIssuerPath = NewPath("https://www.w3.org/2018/credentials#issuer") )
var ContextURLNotAllowedErr = errors.New("context not on the remoteallowlist")
var ErrInvalidValue = errors.New("invalid value")
ErrInvalidValue is returned when an invalid value is parsed
Functions ¶
func AddContext ¶
AddContext adds the context to the @context array. It makes sure no duplicates will exist.
func AllFieldsDefined ¶
func AllFieldsDefined(DocumentLoader ld.DocumentLoader, inputJSON []byte) error
AllFieldsDefined tests whether all fields are defined in the JSON-LD context(s) of the input.
func DefaultAllowList ¶
func DefaultAllowList() []string
DefaultAllowList returns the default allow list for external contexts
func JWS2020ContextV1URI ¶
JWS2020ContextV1URI returns JWS2020ContextV1 as a URI
func NewContextLoader ¶
func NewContextLoader(allowUnlistedExternalCalls bool, contexts ContextsConfig) (ld.DocumentLoader, error)
NewContextLoader creates a new JSON-LD context loader with the embedded FS as first loader. It loads the most used context from the embedded FS. This ensures the contents cannot be altered. If allowExternalCalls is set to true, it also loads external context from the internet.
func NewEmbeddedFSDocumentLoader ¶
func NewEmbeddedFSDocumentLoader(fs embed.FS, nextLoader ld.DocumentLoader) ld.DocumentLoader
NewEmbeddedFSDocumentLoader creates a new embeddedFSDocumentLoader for an embedded filesystem.
func NewFilteredLoader ¶
func NewFilteredLoader(allowedURLs []string, nextLoader ld.DocumentLoader) ld.DocumentLoader
NewFilteredLoader accepts a list of allowed urls and a nextLoader and creates a new filteredDocumentLoader
func NewMappedDocumentLoader ¶
func NewMappedDocumentLoader(mapping map[string]string, nextLoader ld.DocumentLoader) ld.DocumentLoader
NewMappedDocumentLoader rewrites document request using a mapping and calls the nextLoader
func TestVC ¶
func TestVC() vc.VerifiableCredential
TestVC returns an instance of the TestCredential
Types ¶
type BoolScalar ¶
type BoolScalar bool
BoolScalar is the boolean version of a Scalar
func (BoolScalar) String ¶
func (bs BoolScalar) String() string
func (BoolScalar) Value ¶
func (bs BoolScalar) Value() interface{}
type Config ¶
type Config struct {
// Contexts contains the configuration for the JSON-LD Contexts
Contexts ContextsConfig `koanf:"contexts"`
}
Config holds the config for the vcr engine
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a fresh Config filled with default values
type ContextsConfig ¶
type ContextsConfig struct {
// RemoteAllowList A list with urls as string which are allowed to request
RemoteAllowList []string `koanf:"remoteallowlist"`
// LocalFileMapping contains a list of context URLs mapped to a local file
LocalFileMapping map[string]string `koanf:"localmapping"`
}
ContextsConfig contains config for json-ld document loader
func DefaultContextConfig ¶
func DefaultContextConfig() ContextsConfig
DefaultContextConfig returns the default list of allowed external resources and a mapping to embedded contexts
type Document ¶
type Document []interface{}
Document represents a JSON-LD document in expanded form. The expanded form is ideal for traversing and finding values
type Float64Scalar ¶
type Float64Scalar float64
Float64Scalar is the float64 version of a Scalar
func (Float64Scalar) String ¶
func (fs Float64Scalar) String() string
func (Float64Scalar) Value ¶
func (fs Float64Scalar) Value() interface{}
type JSONLD ¶
type JSONLD interface {
// DocumentLoader returns the JSON-LD DocumentLoader
DocumentLoader() ld.DocumentLoader
}
JSONLD defines the interface of a JSON utilities engine. It allows sharing instances of utils over engines.
func NewJSONLDInstance ¶
func NewJSONLDInstance() JSONLD
NewJSONLDInstance creates a new instance of the jsonld struct which implements the JSONLD interface
func NewTestJSONLDManager ¶
NewTestJSONLDManager creates a new test context manager which contains extra test contexts
type LDUtil ¶
type LDUtil struct {
LDDocumentLoader ld.DocumentLoader
}
LDUtil package a set of often used JSON-LD operations for re-usability.
func (LDUtil) Canonicalize ¶
Canonicalize canonicalizes the json-ld input according to the URDNA2015 [RDF-DATASET-NORMALIZATION] algorithm.
type Path ¶
type Path []string
Path is used to traverse an expanded JSON-LD document Its elements are IRIs
type Reader ¶
type Reader struct {
// DocumentLoader the document loader that resolves JSON-LD context urls
DocumentLoader ld.DocumentLoader
// AllowUndefinedProperties specifies whether the reader should return an error when it occurs a property that is not defined in the JSON-LD context.
AllowUndefinedProperties bool
}
Reader adds Document reader functions for a JSON-LD context.
type Scalar ¶
type Scalar interface {
fmt.Stringer
// Value returns the underlying value (string, float, true or false)
Value() interface{}
}
Scalar represents a JSON-LD scalar (string, number, true or false)
func MustParseScalar ¶
func MustParseScalar(value interface{}) Scalar
MustParseScalar returns a Scalar based on an interface value. It panics when the value is not supported.
func ParseScalar ¶
ParseScalar returns a Scalar based on an interface value. It returns ErrInvalidValue for unsupported values.
type StringScalar ¶
type StringScalar string
StringScalar is the string version of a Scalar
func (StringScalar) String ¶
func (ss StringScalar) String() string
func (StringScalar) Value ¶
func (ss StringScalar) Value() interface{}