schemameta

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package schemameta handles parsing, inference, and validation of TS11 SchemaMeta objects.

Index

Constants

This section is empty.

Variables

View Source
var FormatMapping = map[string]string{
	".vctm.json": "dc+sd-jwt",
	".mdoc.json": "mso_mdoc",
	".vc.json":   "jwt_vc_json",
}

FormatMapping maps file extensions to TS11 format identifiers.

View Source
var LegacyVCTMExtensions = []string{".vctm.json", ".vctm"}

LegacyVCTMExtensions lists file extensions that indicate a legacy VCTM file (JSON content) that can be used for credential discovery when no schema-meta exists.

View Source
var UUIDNamespace = uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") // DNS namespace

UUIDNamespace is the UUID v5 namespace for registry.siros.org schema IDs.

View Source
var ValidAttestationLoS = map[string]bool{
	"iso_18045_high":           true,
	"iso_18045_moderate":       true,
	"iso_18045_enhanced-basic": true,
	"iso_18045_basic":          true,
}

ValidAttestationLoS lists the normative TS11 attestation LoS values.

View Source
var ValidBindingType = map[string]bool{
	"claim":     true,
	"key":       true,
	"biometric": true,
	"none":      true,
}

ValidBindingType lists the normative TS11 binding type values.

View Source
var ValidSupportedFormats = map[string]bool{
	"dc+sd-jwt":      true,
	"mso_mdoc":       true,
	"jwt_vc_json":    true,
	"jwt_vc_json-ld": true,
	"ldp_vc":         true,
}

ValidSupportedFormat returns true if the format identifier is one of the normative TS11 supported formats.

Functions

func DetectFormats

func DetectFormats(dir, slug string) (formats []string, files map[string]string, err error)

DetectFormats scans a directory for known credential format files matching a slug and returns the detected format identifiers and file paths. It checks FormatMapping extensions first, then falls back to bare .vctm extension, and finally checks for bare {slug}.json as a VCTM (dc+sd-jwt) file.

func GenerateID

func GenerateID(org, slug string) string

GenerateID produces a deterministic UUID v5 from org/slug.

func NormalizeAttestationLoS added in v0.7.0

func NormalizeAttestationLoS(v string) string

NormalizeAttestationLoS maps legacy/friendly values to normative TS11 enum values.

func NormalizeBindingType added in v0.7.0

func NormalizeBindingType(v string) string

NormalizeBindingType maps legacy/friendly values to normative TS11 enum values.

func ValidSupportedFormat added in v0.7.0

func ValidSupportedFormat(f string) bool

ValidSupportedFormat checks whether a format string is in the normative enum.

Types

type LegacyCredential added in v0.9.9

type LegacyCredential struct {
	Slug string // credential slug
	Dir  string // directory containing the format files
}

LegacyCredential describes a credential discovered via format files (no schema-meta).

func DetectLegacyCredentials

func DetectLegacyCredentials(dir string, knownSlugs map[string]bool) ([]LegacyCredential, error)

DetectLegacyCredentials scans a directory tree for VCTM files (.vctm.json or .vctm) that do NOT have a corresponding schema-meta file, returning their slugs and directories.

type SchemaMeta

type SchemaMeta struct {
	ID                 string           `json:"id"`
	Version            string           `json:"version"`
	AttestationLoS     string           `json:"attestationLoS"`
	BindingType        string           `json:"bindingType"`
	SupportedFormats   []string         `json:"supportedFormats"`
	SchemaURIs         []SchemaURI      `json:"schemaURIs"`
	RulebookURI        string           `json:"rulebookURI,omitempty"`
	TrustedAuthorities []TrustAuthority `json:"trustedAuthorities,omitempty"`
}

SchemaMeta is the full TS11 SchemaMeta object, combining authored and inferred fields.

func Infer

func Infer(src *SchemaMetaSource, org, slug, baseURL string, formats []string, formatFiles map[string]string) *SchemaMeta

Infer builds a complete SchemaMeta from authored source fields, detected formats, and context.

func InferLegacy

func InferLegacy(org, slug, baseURL string, formats []string, formatFiles map[string]string) *SchemaMeta

InferLegacy builds a SchemaMeta for a credential discovered via VCTM files only (no schema-meta.yaml). These will not pass TS11 validation.

type SchemaMetaSource

type SchemaMetaSource struct {
	AttestationLoS     string           `yaml:"attestation_los" json:"attestationLoS"`
	BindingType        string           `yaml:"binding_type" json:"bindingType"`
	Version            string           `yaml:"version,omitempty" json:"version,omitempty"`
	TrustedAuthorities []TrustAuthority `yaml:"trusted_authorities,omitempty" json:"trustedAuthorities,omitempty"`
	RulebookURI        string           `yaml:"rulebook_uri,omitempty" json:"rulebookURI,omitempty"`
}

SchemaMetaSource represents the manually-authored fields from schema-meta.yaml.

func ParseSource

func ParseSource(path string) (*SchemaMetaSource, error)

ParseSource reads a schema-meta.yaml (or .json) file.

type SchemaURI

type SchemaURI struct {
	FormatIdentifier string `json:"formatIdentifier"`
	URI              string `json:"uri"`
}

SchemaURI represents a format-specific schema reference (TS11 Section 4.3.2).

type TrustAuthority added in v0.7.0

type TrustAuthority struct {
	FrameworkType string `yaml:"framework_type" json:"frameworkType"`
	Value         string `yaml:"value" json:"value"`
	IsLOTE        *bool  `yaml:"is_lote,omitempty" json:"isLOTE,omitempty"`
}

TrustAuthority represents a trust framework reference per TS11 Section 4.3.3.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates SchemaMeta objects against the TS11 JSON schema.

func NewValidator

func NewValidator() (*Validator, error)

NewValidator creates a validator using the embedded TS11 JSON schema.

func (*Validator) Validate

func (v *Validator) Validate(sm *SchemaMeta) error

Validate checks a SchemaMeta object against the TS11 JSON schema.

func (*Validator) ValidateRaw added in v0.7.0

func (v *Validator) ValidateRaw(obj any) error

ValidateRaw checks a raw map against the TS11 JSON schema. This is used to test additionalProperties enforcement.

Jump to

Keyboard shortcuts

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