contract

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package contract wires Vault into the Forge dashboard's contract path. It registers the `vault` contributor with the dashboard's contract registry and answers its intents from the live Vault instance.

This package is the surface the React dashboard shell reads. The templ dashboard it once ran beside is gone; MIGRATION.md at the repo root records what moved.

Index

Constants

View Source
const ContributorName = "vault"

ContributorName is the join key between this contract and packages/plugin-vault's `extension` field, and matches extension.ExtensionName. A mismatch hides the React plugin with no error anywhere, because that is what an uninstalled extension looks like.

Variables

This section is empty.

Functions

func Register

func Register(
	d *dispatcher.Dispatcher,
	reg contract.Registry,
	wreg contract.WardenRegistry,
	deps Deps,
) error

Register loads the embedded manifest, validates it, registers the `vault` contributor with reg, and binds the handlers against deps.

Types

type AuditSummary

type AuditSummary struct {
	ID       string `json:"id"`
	Action   string `json:"action"`
	Resource string `json:"resource"`
	Key      string `json:"key"`
	Outcome  string `json:"outcome"`
	TenantID string `json:"tenantId,omitempty"`
	UserID   string `json:"userId,omitempty"`
	// Error is the failure's message, read from the row's metadata. It is
	// empty on a success row and on a failure row that recorded none.
	Error     string `json:"error,omitempty"`
	CreatedAt string `json:"createdAt"`
}

AuditSummary is the wire projection of one audit log entry. The detail pages and the audit list share it, so it carries every column the audit list shows. TenantID, UserID and Error are omitted when empty: an app write has no user, and only a failure row has an error.

type ConfigEntrySummary

type ConfigEntrySummary struct {
	ID    string `json:"id"`
	Key   string `json:"key"`
	Value any    `json:"value"`
	// ValueType is the label stored with the entry. The store keeps it as
	// free text, so it is not always one of the six the vault validates:
	// see KnownType.
	ValueType string `json:"valueType"`
	// KnownType is false for a label the vault does not validate (the templ
	// page's "yaml", say). Such an entry is readable but its value cannot be
	// judged, so ValueMatchesType is false for it as well.
	KnownType bool `json:"knownType"`
	// ValueMatchesType is false when the stored value is not a value of
	// ValueType, e.g. a string "abc" on an int entry.
	ValueMatchesType bool              `json:"valueMatchesType"`
	Version          int64             `json:"version"`
	Description      string            `json:"description"`
	Metadata         map[string]string `json:"metadata"`
	CreatedAt        string            `json:"createdAt"`
	UpdatedAt        string            `json:"updatedAt"`
}

ConfigEntrySummary is the wire projection of a config entry. Its value leaves through wireValue, so every backend produces the same JSON shape.

type ConfigVersionSummary

type ConfigVersionSummary struct {
	Version          int64  `json:"version"`
	Value            any    `json:"value"`
	ValueMatchesType bool   `json:"valueMatchesType"`
	CreatedAt        string `json:"createdAt"`
	Current          bool   `json:"current"`
}

ConfigVersionSummary is the wire projection of one historical version. A version keeps only its value, so ValueMatchesType is judged against the entry's current type, and Current marks the version the entry is at now.

type Deps

type Deps struct {
	// Vault is the composed vault. Required. Every handler operates on
	// Vault.AppID() and nothing else: no request carries an app id.
	Vault *vault.Vault

	// Logger receives an Error-level entry for every error a handler maps
	// to CodeInternal, so an operator can find out why a dashboard request
	// failed. Optional: nil means nothing is logged.
	Logger forge.Logger
}

Deps bundles what the contract handlers need at registration time.

type FlagOverrideSummary

type FlagOverrideSummary struct {
	TenantID         string `json:"tenantId"`
	Value            any    `json:"value"`
	ValueMatchesType bool   `json:"valueMatchesType"`
	UpdatedAt        string `json:"updatedAt"`
}

FlagOverrideSummary is the wire projection of one per-tenant override.

type FlagRuleSummary

type FlagRuleSummary struct {
	ID       string `json:"id"`
	Priority int    `json:"priority"`
	Type     string `json:"type"`
	// Implemented is false for when_tenant_tag and custom: the engine never
	// matches them.
	Implemented bool     `json:"implemented"`
	TenantIDs   []string `json:"tenantIds"`
	UserIDs     []string `json:"userIds"`
	Percentage  int      `json:"percentage"`
	// StartAt and EndAt are UTC RFC3339, omitted for an open end.
	StartAt           *string        `json:"startAt,omitempty"`
	EndAt             *string        `json:"endAt,omitempty"`
	TagKey            string         `json:"tagKey,omitempty"`
	TagValue          string         `json:"tagValue,omitempty"`
	Evaluator         string         `json:"evaluator,omitempty"`
	Params            map[string]any `json:"params,omitempty"`
	ReturnValue       any            `json:"returnValue"`
	ReturnMatchesType bool           `json:"returnMatchesType"`
}

FlagRuleSummary is the wire projection of one targeting rule.

type FlagSummary

type FlagSummary struct {
	ID   string `json:"id"`
	Key  string `json:"key"`
	Type string `json:"type"`
	// DefaultValue is whatever is stored, which is not always a value of
	// Type: see DefaultMatchesType.
	DefaultValue any `json:"defaultValue"`
	// DefaultMatchesType is false when the stored default is not a value of
	// Type, e.g. the templ page's string "true" on a bool flag.
	DefaultMatchesType bool     `json:"defaultMatchesType"`
	Description        string   `json:"description"`
	Tags               []string `json:"tags"`
	Enabled            bool     `json:"enabled"`
	CreatedAt          string   `json:"createdAt"`
	UpdatedAt          string   `json:"updatedAt"`
}

FlagSummary is the wire projection of a flag definition. Its values leave through wireValue, so every backend produces the same JSON shape.

type FlagTraceStep

type FlagTraceStep struct {
	RuleID   string `json:"ruleId"`
	Priority int    `json:"priority"`
	Type     string `json:"type"`
	Matched  bool   `json:"matched"`
	Reached  bool   `json:"reached"`
	Note     string `json:"note"`
}

FlagTraceStep is the wire projection of one rule the engine considered during an explained evaluation. RuleID is the rule's id. Note has no omitempty: a rule the engine never reached carries "".

type FlagVariantSummary

type FlagVariantSummary struct {
	Value       any    `json:"value"`
	Description string `json:"description"`
}

FlagVariantSummary is the wire projection of one named variant.

type OverrideSummary

type OverrideSummary struct {
	Key      string `json:"key"`
	TenantID string `json:"tenantId"`
	Value    any    `json:"value"`
	// ValueMatchesType is judged against the type of the key's entry, and is
	// false when the entry no longer exists.
	ValueMatchesType bool `json:"valueMatchesType"`
	// KeyExists is false for an orphan: an override whose config entry is
	// gone. It still resolves for its tenant, because the resolver returns
	// an override before it reads the entry. Deleting the key normally
	// removes the overrides with it, so an orphan is an older or foreign
	// write, and overrides.delete can remove it.
	KeyExists bool   `json:"keyExists"`
	UpdatedAt string `json:"updatedAt"`
}

OverrideSummary is the wire projection of one per-tenant config override.

type RotationPolicySummary

type RotationPolicySummary struct {
	ID              string `json:"id"`
	SecretKey       string `json:"secretKey"`
	IntervalSeconds int64  `json:"intervalSeconds"`
	Enabled         bool   `json:"enabled"`
	// Rotatable reports whether an application has registered a rotator
	// for this key. A policy without one will never rotate, however due it
	// gets: the loop logs an error every minute and changes nothing.
	Rotatable      bool    `json:"rotatable"`
	LastRotatedAt  *string `json:"lastRotatedAt,omitempty"`
	NextRotationAt *string `json:"nextRotationAt,omitempty"` // omitted when disabled
	CreatedAt      string  `json:"createdAt"`
	UpdatedAt      string  `json:"updatedAt"`
}

RotationPolicySummary is the wire projection of a rotation policy.

type RotationRecordSummary

type RotationRecordSummary struct {
	ID         string `json:"id"`
	OldVersion int64  `json:"oldVersion"`
	NewVersion int64  `json:"newVersion"`
	RotatedBy  string `json:"rotatedBy,omitempty"`
	RotatedAt  string `json:"rotatedAt"`
}

RotationRecordSummary is the wire projection of one completed rotation event.

type SecretSummary

type SecretSummary struct {
	ID      string `json:"id"`
	Key     string `json:"key"`
	Version int64  `json:"version"`
	// EncryptionAlg names the algorithm the stored value was encrypted
	// with. It has no omitempty: an empty string must reach the client as
	// "", because absence and "not encrypted" must not be confusable, and
	// "" is what every row written by an unconfigured Vault produces.
	EncryptionAlg string            `json:"encryptionAlg"`
	ExpiresAt     *string           `json:"expiresAt,omitempty"` // RFC3339
	AppID         string            `json:"appId"`
	Metadata      map[string]string `json:"metadata,omitempty"`
	CreatedAt     string            `json:"createdAt"`
	UpdatedAt     string            `json:"updatedAt"`
}

SecretSummary is the wire projection of a secret's metadata. It never carries a value: only secrets.create and secrets.update ever put one on the wire, and only in their request, never a response.

type SecretVersionSummary

type SecretVersionSummary struct {
	ID        string `json:"id"`
	Version   int64  `json:"version"`
	CreatedBy string `json:"createdBy,omitempty"`
	CreatedAt string `json:"createdAt"`
	// Encryption is "encrypted", "plaintext", or "unknown" for a version
	// written before versions recorded how they were stored and not yet
	// classified.
	Encryption string `json:"encryption"`
}

SecretVersionSummary is the wire projection of one historical version's metadata. Like SecretSummary, it never carries a value.

Jump to

Keyboard shortcuts

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