Documentation
¶
Overview ¶
Package formats provides the interface and registry for credential metadata format generators
Index ¶
- Variables
- func FormatJSON(data interface{}) ([]byte, error)
- func List() []string
- func ParseFormats(formatStr string) ([]string, error)
- func Register(g Generator)
- func ResolveAlias(name string) string
- type ClaimDefinition
- type ClaimLocalization
- type DisplayLocalization
- type Generator
- type ImageRef
- type ParsedCredential
- type Registry
Constants ¶
This section is empty.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the global format registry
Functions ¶
func FormatJSON ¶
FormatJSON is a helper to marshal data as indented JSON
func ParseFormats ¶
ParseFormats parses formats using the default registry
func ResolveAlias ¶ added in v0.12.0
ResolveAlias maps a user-facing format name to its internal registry name. If no alias is defined the input is returned unchanged.
Types ¶
type ClaimDefinition ¶
type ClaimDefinition struct {
// Name is the claim identifier
Name string
// Path for nested claims (e.g., ["address", "street"])
Path []string
// DisplayName is the human-readable label
DisplayName string
// Type is the data type (string, number, boolean, date, datetime, image, object, array)
Type string
// Description of the claim
Description string
// Mandatory indicates if the claim is required
Mandatory bool
// SD indicates selective disclosure setting
SD string
// SvgId for SVG template reference
SvgId string
// Localizations per locale
Localizations map[string]ClaimLocalization
// FormatMappings maps format name to claim name override
FormatMappings map[string]string
// Children contains nested claim definitions for object and array types
Children []ClaimDefinition
}
ClaimDefinition represents a format-agnostic claim
type ClaimLocalization ¶
ClaimLocalization contains localized claim display
type DisplayLocalization ¶
DisplayLocalization contains localized display properties
type Generator ¶
type Generator interface {
// Name returns the format identifier (e.g., "vctm", "mddl", "w3c")
Name() string
// Description returns a human-readable description of the format
Description() string
// FileExtension returns the output file extension (without dot)
FileExtension() string
// Generate produces the format-specific output
Generate(parsed *ParsedCredential, cfg *config.Config) ([]byte, error)
// DeriveIdentifier derives the format-specific ID from the parsed credential
DeriveIdentifier(parsed *ParsedCredential, cfg *config.Config) string
}
Generator is the interface for format-specific generators
type ParsedCredential ¶
type ParsedCredential struct {
// Core identifiers
ID string // Short identifier (derived from filename if not specified)
Name string // Human-readable name
// Format-specific identifiers (may be derived or explicit)
VCT string // SD-JWT VC type identifier
DocType string // mso_mdoc document type
Namespace string // mso_mdoc namespace
W3CTypes []string // W3C VC type array
W3CContext []string // W3C VC @context
// Description
Description string
// Display properties
BackgroundColor string
TextColor string
LogoPath string
LogoAltText string
LogoAbsPath string
// SVG Template for rendering
SVGTemplatePath string
SVGTemplateURI string
SVGTemplateIntegrity string
// Source file info (for resolving relative paths)
SourcePath string
SourceDir string
// Generation options
InlineImages bool
// Localizations
Localizations map[string]DisplayLocalization
// Claims
Claims []ClaimDefinition
// Images
Images []ImageRef
// Format-specific overrides from front matter
FormatOverrides map[string]map[string]interface{}
// Claim mappings per format
ClaimMappings map[string]map[string]string
// Raw metadata from front matter
Metadata map[string]interface{}
// Formats is an optional per-credential format override (e.g. "sd-jwt,w3c").
// When set, only the listed formats are generated for this credential.
// When empty, all registered formats are generated (caller decides).
Formats string
}
ParsedCredential represents format-agnostic parsed credential metadata
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered format generators
func (*Registry) ParseFormats ¶
ParseFormats parses a comma-separated format string into a list of format names "all" returns all registered formats
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mddl provides the MDDL format generator for mso_mdoc credentials (ISO 18013-5)
|
Package mddl provides the MDDL format generator for mso_mdoc credentials (ISO 18013-5) |
|
Package vctmfmt provides the VCTM format generator for SD-JWT VC credentials
|
Package vctmfmt provides the VCTM format generator for SD-JWT VC credentials |
|
Package w3c provides the W3C VC format generator for W3C VCDM 2.0 credentials
|
Package w3c provides the W3C VC format generator for W3C VCDM 2.0 credentials |