clientmodels

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultFallbackLanguage = "en"

Variables

This section is empty.

Functions

func ClaimPathKey

func ClaimPathKey(path []any) string

ClaimPathKey produces a deterministic string key from a claim path for use in maps. Go slices can't be map keys, so this serializes the path.

Each element is type-prefixed and delimited so different paths can't collide via formatting accidents (e.g. ["a b"] vs ["a", "b"]). Whole-value float64s — the form JSON unmarshaling produces — are coerced to integer form so a JSON-decoded path matches a Go-literal int path. Unknown element types fall back to a generic format so callers always get a string.

func SatisfiesRequestedAttributes

func SatisfiesRequestedAttributes(given, requested []Attribute) (bool, []string)

SatisfiesRequestedAttributes checks that `given` contains everything needed to satisfy `requested`. Returns ok + list of issues with paths (e.g. "address.street").

Types

type Attribute

type Attribute struct {
	// Canonical identifier: the full claim path as an array of strings and integers.
	// Examples:
	//   ["email"]                    — flat IRMA attribute
	//   ["address", "street"]        — nested SD-JWT claim
	//   ["courses", 1]              — specific array element
	//   ["departments", 0, "name"]  — nested object inside array
	//
	// The UI sends this path back verbatim in SelectedCredential.AttributePaths
	// when the user grants disclosure permission.
	ClaimPath []any `json:"claim_path"`

	// Human-readable name for this attribute, localized.
	// Nil for array item attributes where the parent's name serves as the label.
	DisplayName *TranslatedString `json:"display_name,omitempty"`

	// Optional longer description for this attribute, localized.
	Description *TranslatedString `json:"description,omitempty"`

	// The actual value of this attribute as provided by the issuer.
	// Nil for section header attributes and unfilled requested attributes.
	Value *AttributeValue `json:"value,omitempty"`

	// The value that a verifier requested for this attribute (if any).
	RequestedValue *AttributeValue `json:"requested_value,omitempty"`
}

Attribute represents a single claim within a credential.

type AttributeType

type AttributeType string

AttributeType indicates the type of an attribute value.

const (
	AttributeType_String      AttributeType = "string"
	AttributeType_Bool        AttributeType = "boolean"
	AttributeType_Int         AttributeType = "integer"
	AttributeType_Image       AttributeType = "image"
	AttributeType_Base64Image AttributeType = "base64_image"
)

type AttributeValue

type AttributeValue struct {
	Type AttributeType `json:"type"`

	Int         *int64  `json:"int,omitempty"`
	Bool        *bool   `json:"bool,omitempty"`
	String      *string `json:"string,omitempty"`
	ImagePath   *string `json:"image_path,omitempty"`
	Base64Image *string `json:"base64_image,omitempty"`
}

AttributeValue holds a single scalar attribute value. Compound types (arrays, objects) are represented as multiple Attribute entries with nested claim paths instead.

func NewAttributeValue

func NewAttributeValue(val any) *AttributeValue

NewAttributeValue converts a scalar Go value into an AttributeValue. Only handles scalar types (string, bool, int64, float64). Returns nil for nil input. Callers must flatten arrays and objects into separate Attribute entries.

func (*AttributeValue) HasValue

func (v *AttributeValue) HasValue() bool

HasValue returns true if this AttributeValue carries an actual value (not just a type constraint).

type AuthorizationCodeFlowRequest

type AuthorizationCodeFlowRequest struct {
	// The state will be the external identifier for this session, so it should be unique and unguessable. The session will generate a random state if this is not set.
	OpenID4VCIState string

	Credentials             []*CredentialDescriptor
	AuthorizationEndpoint   string
	AuthorizationParameters map[string][]string // url.Values
}

AuthorizationCodeFlowRequest is a request to proceed with an authorization code issuance flow.

type Credential

type Credential struct {
	// The id for this credential. For IRMA/idemix credentials this would look like
	// "pbdf.sidn-pbdf.email", for EUDI credentials this is the VCT URL.
	CredentialId string `json:"credential_id"`
	// Hash over all attribute values and the credential id.
	Hash string `json:"hash"`
	// Base64-encoded image for this credential.
	Image *Image `json:"image,omitempty"`
	// The display name for this credential, localized.
	Name TranslatedString `json:"name"`
	// All information about the credential issuer.
	Issuer TrustedParty `json:"issuer"`
	// The IDs for all instances of this credential in all different formats.
	CredentialInstanceIds map[CredentialFormat]string `json:"credential_instance_ids"`
	// The number of credential instances left per format (batched issuance).
	BatchInstanceCountsRemaining map[CredentialFormat]*uint `json:"batch_instance_counts_remaining"`
	// All the attributes and their values in this credential.
	// Ordered by the source metadata (IRMA scheme or EUDI issuer metadata).
	// Nested objects and arrays are flattened with full claim paths.
	Attributes []Attribute `json:"attributes"`
	// The date and time (unix format) at which this credential was issued.
	IssuanceDate *int64 `json:"issuance_date"`
	// The date and time (unix format) when this credential expires (0 if no expiry).
	ExpiryDate *int64 `json:"expiry_date"`
	// Whether or not this credential has been revoked.
	Revoked bool `json:"revoked"`
	// Whether or not revocation is supported for this credential.
	RevocationSupported bool `json:"revocation_supported"`
	// URL at which this credential can be issued (if any).
	IssueURL *TranslatedString `json:"issue_url"`
}

Credential represents a full credential with all its metadata and attribute values.

type CredentialDescriptor

type CredentialDescriptor struct {
	CredentialId string            `json:"credential_id"`
	Name         TranslatedString  `json:"name"`
	Issuer       TrustedParty      `json:"issuer"`
	Category     *TranslatedString `json:"category,omitempty"`
	Image        *Image            `json:"image,omitempty"`
	Attributes   []Attribute       `json:"attributes"`
	IssueURL     *TranslatedString `json:"issue_url,omitempty"`
}

CredentialDescriptor describes a credential type without any instance-specific values.

type CredentialFormat

type CredentialFormat string

CredentialFormat identifies the format of a credential.

const (
	Format_SdJwtVc CredentialFormat = "dc+sd-jwt"
	Format_Idemix  CredentialFormat = "idemix"
)

type CredentialStoreItem

type CredentialStoreItem struct {
	Credential CredentialDescriptor `json:"credential"`
	Faq        Faq                  `json:"faq"`
}

CredentialStoreItem is a credential descriptor with FAQ information.

type DisclosureBundle

type DisclosureBundle struct {
	// The credentials the user discloses together when this bundle is picked.
	// Each credential's Attributes list holds only the attrs from THIS con that
	// come from THIS instance — never a cross-con union.
	Credentials []*SelectableCredentialInstance `json:"credentials"`
}

DisclosureBundle is a set of owned credential instances that together satisfy one inner con of a discon. For most disclosure requests this contains exactly one credential. Cons that require multiple singletons (or one non-singleton plus singletons) produce bundles with multiple credentials.

type DisclosureDisconSelection

type DisclosureDisconSelection struct {
	Credentials []SelectedCredential `json:"credentials"`
}

DisclosureDisconSelection is the list of selected credentials for a disjunction.

type DisclosureLog

type DisclosureLog struct {
	Protocol    Protocol        `json:"protocol"`
	Credentials []LogCredential `json:"credentials"`
	Verifier    *TrustedParty   `json:"verifier"`
}

DisclosureLog is a log of a disclosure session.

type DisclosurePickOne

type DisclosurePickOne struct {
	// If true, the user can skip this because it isn't required
	Optional bool `json:"optional"`
	// If true, the user can select multiple bundles (OpenID4VP "multiple" flag)
	Multiple bool `json:"multiple"`
	// The user can pick one (or more, if Multiple) of these without having to issue.
	// Each bundle satisfies exactly one inner con of the discon; selecting a bundle
	// means disclosing every credential inside it together.
	OwnedOptions []*DisclosureBundle `json:"owned_options"`
	// The user can issue one of these and then use it
	ObtainableOptions []*CredentialDescriptor `json:"obtainable_options"`
}

DisclosurePickOne is a disjunction where the user needs to pick one or more bundles.

type DisclosurePlan

type DisclosurePlan struct {
	// What to show during issuance during disclosure.
	// If nil then no issuances are required before a valid choice can be made.
	IssueDuringDisclosure *IssueDuringDisclosure `json:"issue_during_disclosure"`
	// What the user can pick for disclosure. This should never be nil.
	DisclosureChoicesOverview []DisclosurePickOne `json:"disclosure_choices_overview"`
}

DisclosurePlan describes how the user can satisfy a disclosure request.

type Faq

type Faq struct {
	Intro   *TranslatedString `json:"intro"`
	Purpose *TranslatedString `json:"purpose"`
	Content *TranslatedString `json:"content"`
	HowTo   *TranslatedString `json:"how_to"`
}

Faq contains FAQ information for a credential type.

type Image

type Image struct {
	// Base64-encoded image data
	Base64 string `json:"base64"`
	// The MIME type of the image (e.g. "image/png")
	MimeType *string `json:"mime_type,omitempty"`
}

func ImageFromFile

func ImageFromFile(path string) *Image

ImageFromFile reads an image file from disk and returns it as a base64-encoded Image. Returns nil if the path is empty or the file cannot be read.

type IssuanceBundle

type IssuanceBundle struct {
	Credentials []*CredentialDescriptor `json:"credentials"`
}

IssuanceBundle is a set of credential descriptors that together satisfy one inner con of an issuance-during-disclosure discon. For most requests this contains exactly one descriptor; cons spanning multiple credential types produce bundles with multiple descriptors.

type IssuanceLog

type IssuanceLog struct {
	Protocol             Protocol        `json:"protocol"`
	Credentials          []LogCredential `json:"credentials"`
	DisclosedCredentials []LogCredential `json:"disclosed_credentials"`
	Issuer               *TrustedParty   `json:"issuer"`
}

IssuanceLog is a log of an issuance session.

type IssuanceStep

type IssuanceStep struct {
	Options []*IssuanceBundle `json:"options"`
}

IssuanceStep is one step in the issuance wizard during disclosure flow. Each option is a bundle of credentials that together satisfy one inner con of the unsatisfied discon. The user picks one bundle and must issue every credential in it.

type IssueDuringDisclosure

type IssueDuringDisclosure struct {
	// The steps to fulfill before we can continue the disclosure
	Steps []IssuanceStep `json:"steps"`
	// The set of credential ids that have been issued during this session
	IssuedCredentialIds map[string]struct{} `json:"issued_credential_ids"`
	// The last credential that was issued with the correct type but with wrong attribute values
	WrongCredentialIssued *Credential `json:"wrong_credential_issued"`
}

IssueDuringDisclosure describes issuance steps needed during a disclosure flow.

type LogCredential

type LogCredential struct {
	CredentialId        string             `json:"credential_id"`
	Formats             []CredentialFormat `json:"formats"`
	Image               *Image             `json:"image,omitempty"`
	Name                TranslatedString   `json:"name"`
	Issuer              TrustedParty       `json:"issuer"`
	Attributes          []Attribute        `json:"attributes"`
	IssuanceDate        *int64             `json:"issuance_date"`
	ExpiryDate          *int64             `json:"expiry_date"`
	Revoked             bool               `json:"revoked"`
	RevocationSupported bool               `json:"revocation_supported"`
	IssueURL            *TranslatedString  `json:"issue_url,omitempty"`
}

LogCredential is a credential entry in a log, containing full credential metadata.

func CredentialToLogCredential

func CredentialToLogCredential(c *Credential) LogCredential

CredentialToLogCredential converts a Credential to a LogCredential, extracting formats from CredentialInstanceIds (falling back to BatchInstanceCountsRemaining).

type LogInfo

type LogInfo struct {
	Type             LogType           `json:"type"`
	Time             time.Time         `json:"time"`
	RemovalLog       *RemovalLog       `json:"removal_log,omitempty"`
	IssuanceLog      *IssuanceLog      `json:"issuance_log,omitempty"`
	DisclosureLog    *DisclosureLog    `json:"disclosure_log,omitempty"`
	SignedMessageLog *SignedMessageLog `json:"signed_message_log,omitempty"`
}

LogInfo is a credential format & protocol agnostic log entry with full credential metadata.

type LogType

type LogType string

LogType identifies the type of a log entry.

const (
	LogType_Disclosure        LogType = "disclosure"
	LogType_Issuance          LogType = "issuance"
	LogType_Signature         LogType = "signature"
	LogType_CredentialRemoval LogType = "removal"
)

type PinInteractionPayload

type PinInteractionPayload struct {
	Pin     string `json:"pin"`
	Proceed bool   `json:"proceed"`
}

PinInteractionPayload is the payload for a PIN entry interaction.

type PreAuthorizedCodeFlowPermissionRequest

type PreAuthorizedCodeFlowPermissionRequest struct {
	Credentials               []*CredentialDescriptor
	TransactionCodeParameters *PreAuthorizedCodeTransactionCodeParameters
	// RemainingAttempts is set when the user is being re-prompted after a wrong
	// transaction code. Nil on the initial prompt.
	RemainingAttempts *int
}

PreAuthorizedCodeFlowPermissionRequest is a request to proceed with a pre-authorized code issuance flow.

type PreAuthorizedCodeTransactionCodeParameters

type PreAuthorizedCodeTransactionCodeParameters struct {
	InputMode   string  `json:"input_mode"`
	Length      *int    `json:"length,omitempty"`
	Description *string `json:"description,omitempty"`
}

PreAuthorizedCodeTransactionCodeParameters describes the parameters for a pre-authorized code transaction code (OID4VCI).

type Protocol

type Protocol string

Protocol identifies the protocol used for a session.

const (
	Protocol_Irma       Protocol = "irma"
	Protocol_OpenID4VP  Protocol = "openid4vp"
	Protocol_OpenID4VCI Protocol = "openid4vci"
)

type RemoteError

type RemoteError struct {
	Status      int    `json:"status,omitempty"`
	ErrorName   string `json:"error,omitempty"`
	Description string `json:"description,omitempty"`
	Message     string `json:"message,omitempty"`
	Stacktrace  string `json:"stacktrace,omitempty"`
}

RemoteError is a server-side error returned by a remote party.

type RemovalLog

type RemovalLog struct {
	Credentials []LogCredential `json:"credentials"`
}

RemovalLog is a log of a credential removal.

type SelectableCredentialInstance

type SelectableCredentialInstance struct {
	// The id for this credential. For IRMA/idemix credentials this would look like
	// "pbdf.sidn-pbdf.email", for EUDI credentials this is the VCT URL.
	CredentialId string `json:"credential_id"`
	// Hash over all attribute values and the credential id.
	Hash string `json:"hash"`
	// Base64-encoded image for this credential.
	Image *Image `json:"image,omitempty"`
	// The display name for this credential, localized.
	Name TranslatedString `json:"name"`
	// All information about the credential issuer.
	Issuer TrustedParty `json:"issuer"`
	// The credential format for this instance.
	Format CredentialFormat `json:"format"`
	// The number of credential instances left for this credential instance.
	BatchInstanceCountRemaining *uint `json:"batch_instance_count_remaining"`
	// The attributes selectable for disclosure, ordered by source metadata.
	// Requested SD claims appear first (in metadata order), non-SD claims after.
	Attributes []Attribute `json:"attributes"`

	// The date and time (unix format) at which this credential was issued.
	IssuanceDate *int64 `json:"issuance_date"`
	// The date and time (unix format) when this credential expires.
	ExpiryDate *int64 `json:"expiry_date"`
	// Whether or not this credential has been revoked.
	Revoked bool `json:"revoked"`
	// Whether or not revocation is supported for this credential.
	RevocationSupported bool `json:"revocation_supported"`
	// URL at which this credential can be issued (if any).
	IssueURL *TranslatedString `json:"issue_url"`
}

SelectableCredentialInstance represents a single credential instance that the user can select for disclosure.

type SelectedCredential

type SelectedCredential struct {
	// The ID for this credential (idemix id or vct)
	CredentialId string `json:"credential_id"`
	// The hash for the specific credential instance
	CredentialHash string `json:"credential_hash"`
	// List of claim path pointers to the attributes the user will share
	AttributePaths [][]any `json:"attribute_paths"`
}

SelectedCredential is a reference to a credential the user has picked for disclosure.

type SessionAuthCodeInteractionPayload

type SessionAuthCodeInteractionPayload struct {
	// CallbackURL is the full redirect URL the authorization server sent to the
	// wallet's redirect_uri. The library parses its query for the authorization
	// code and state on success, or the error/error_description on failure
	// (RFC 6749 §4.1.2). Set only when Proceed is true.
	CallbackURL *string `json:"callback_url,omitempty"`
	Proceed     bool    `json:"proceed"`
}

SessionAuthCodeInteractionPayload is the payload for an authorization code interaction.

type SessionError

type SessionError struct {
	ErrorType    string       `json:"error_type"`
	WrappedError string       `json:"wrapped_error"`
	Info         string       `json:"info"`
	RemoteError  *RemoteError `json:"remote_error,omitempty"`
	RemoteStatus int          `json:"remote_status"`
	Stack        string       `json:"stack"`
}

SessionError is a frontend-friendly representation of a session error.

type SessionHandler

type SessionHandler interface {
	UpdateSession(session SessionState)
}

SessionHandler is the callback interface for receiving session state updates.

type SessionPermissionInteractionPayload

type SessionPermissionInteractionPayload struct {
	// Whether or not the user agreed to sharing, signing or disclosing
	Granted bool `json:"granted"`
	// The list of discons for each outer con
	DisclosureChoices []DisclosureDisconSelection `json:"disclosure_choices"`
}

SessionPermissionInteractionPayload is the payload for a permission interaction.

type SessionPreAuthorizedCodeInteractionPayload

type SessionPreAuthorizedCodeInteractionPayload struct {
	TransactionCode *string `json:"transaction_code,omitempty"`
	Proceed         bool    `json:"proceed"`
}

SessionPreAuthorizedCodeInteractionPayload is the payload for a pre-authorized code interaction.

type SessionState

type SessionState struct {
	// The identifier for this session
	Id int `json:"id"`
	// The protocol used for this session
	Protocol Protocol `json:"protocol"`
	// The type of session this is
	Type SessionType `json:"type"`
	// In what stage this session currently is
	Status SessionStatus `json:"status"`
	// Who started this session
	Requestor TrustedParty `json:"requestor"`
	// The pairing code to show to the user when the status is pairing
	PairingCode string `json:"pairing_code"`
	// The list of credentials offered to the user. The user has no choice other than accepting or denying them.
	OfferedCredentials []*Credential `json:"offered_credentials"`
	// The plan for disclosing credentials to satisfy this disclosure session
	// Nil when no disclosure has to be done. Can also be present during issuance session.
	DisclosurePlan *DisclosurePlan `json:"disclosure_plan"`
	// The message that should be signed during this session, if any
	MessageToSign string `json:"message_to_sign"`
	// The error when this session has an error
	Error *SessionError `json:"error,omitempty"`
	// The client return url when the app should redirect to after the session, if any
	ClientReturnUrl string `json:"client_return_url"`
	// If this is true then the frontend should not return to the browser after the session is done
	ContinueOnSecondDevice bool `json:"continue_on_second_device"`
	// The number of attempts the user still has to enter a correct pin
	RemainingPinAttempts  *int `json:"remaining_pin_attempts,omitempty"`
	PinBlockedTimeSeconds *int `json:"pin_blocked_time_seconds,omitempty"`

	// OID4VCI specific fields
	OfferedCredentialTypes []*CredentialDescriptor `json:"offered_credential_types"`

	// OID4VCI - Authorization Code Flow parameters
	OpenID4VCIState         string `json:"openid4vci_state,omitempty"`
	AuthorizationRequestUrl string `json:"authorization_request_url,omitempty"`

	// OID4VCI - Pre-Authorized Code Flow parameters
	TransactionCodeParameters *PreAuthorizedCodeTransactionCodeParameters `json:"transaction_code_parameters,omitempty"`
	// Remaining transaction-code attempts. Nil on the initial prompt; populated
	// (e.g. 2, then 1) after each rejected attempt so the UI can show "try again".
	RemainingTxCodeAttempts *int `json:"remaining_tx_code_attempts,omitempty"`
}

SessionState is a snapshot of the state of a session.

type SessionStatus

type SessionStatus string

SessionStatus represents the current status of a session.

const (
	Status_RequestPermission        SessionStatus = "request_permission"
	Status_ShowPairingCode          SessionStatus = "show_pairing_code"
	Status_Success                  SessionStatus = "success"
	Status_Error                    SessionStatus = "error"
	Status_Dismissed                SessionStatus = "dismissed"
	Status_RequestPin               SessionStatus = "request_pin"
	Status_RequestPreAuthorizedCode SessionStatus = "request_pre_authorized_code"
	Status_RequestAuthorizationCode SessionStatus = "request_authorization_code"
)

type SessionType

type SessionType string

SessionType represents the type of a session.

const (
	Type_Disclosure SessionType = "disclosure"
	Type_Issuance   SessionType = "issuance"
	Type_Signature  SessionType = "signature"
)

type SessionUserInteraction

type SessionUserInteraction struct {
	// The ID corresponding to the session this interaction belongs to
	SessionId int `json:"session_id"`
	// The type of interaction performed by the user
	Type UserInteractionType `json:"type"`
	// The payload for this interaction
	Payload any `json:"payload"`
}

SessionUserInteraction represents a user interaction with a session.

type SignedMessageLog

type SignedMessageLog struct {
	DisclosureLog
	Message string `json:"message"`
}

SignedMessageLog is a log of a signature session.

type TranslatedString

type TranslatedString map[string]string

TranslatedString is a map from language code to translated text.

func NewTranslatedString

func NewTranslatedString(value *string) TranslatedString

NewTranslatedString returns a TranslatedString containing the specified string for each supported language, or nil when attr is nil.

type TrustedParty

type TrustedParty struct {
	Id string `json:"id"`
	// Display name for the party
	Name TranslatedString `json:"name"`
	// Url for the party (which can be different per language)
	Url *TranslatedString `json:"url"`
	// The image data for this party.
	Image *Image `json:"image,omitempty"`
	// The trust chain for this party (if any)
	Parent *TrustedParty `json:"parent"`
	// Whether this party is verified by the scheme manager
	Verified bool `json:"verified"`
}

TrustedParty represents an issuer, verifier, or scheme manager.

type UserInteractionType

type UserInteractionType string

UserInteractionType identifies the type of user interaction.

const (
	UI_EnteredPin        UserInteractionType = "entered_pin"
	UI_Permission        UserInteractionType = "permission"
	UI_DismissSession    UserInteractionType = "dismiss"
	UI_AuthorizationCode UserInteractionType = "authorization_code"
	UI_PreAuthorizedCode UserInteractionType = "pre_authorized_code"
)

Jump to

Keyboard shortcuts

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