definition

package
v0.39.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSecretKeyMissing indicates an encrypted auth parameter was loaded
	// but vef.integration.secret_key is not configured, so it cannot be
	// decrypted.
	ErrSecretKeyMissing = errors.New("integration: encrypted auth parameter found but vef.integration.secret_key is not configured")

	// ErrMaskedSecretWithoutPrior indicates a save submitted the masked
	// placeholder for a sensitive parameter that has no stored value to keep.
	ErrMaskedSecretWithoutPrior = errors.New("integration: masked auth parameter has no stored value")
)

Functions

func CompileEnvelopeRequestScript

func CompileEnvelopeRequestScript(script string) (*js.Program, error)

CompileEnvelopeRequestScript compiles a system-level request envelope script: the body sees the outgoing request as `request` and a top-level return statement yields the request to put on the wire. Unlike adapter scripts the wrapper is not invoked — it evaluates to a function the http library calls once per outbound request.

func CompileEnvelopeResponseScript

func CompileEnvelopeResponseScript(script string) (*js.Program, error)

CompileEnvelopeResponseScript compiles a system-level response envelope script: the body sees the completed response as `response` and a top-level return statement yields what the adapter's call returns.

func CompileSchema

func CompileSchema(raw json.RawMessage) (*jsonschema.Resolved, error)

CompileSchema parses and resolves raw as a self-contained JSON Schema (draft 2020-12). Remote $ref references are rejected — contract schemas live in the database and must validate deterministically and offline.

func CompileScript

func CompileScript(script string) (*js.Program, error)

CompileScript compiles an adapter script into the executable form the invoker runs: the body is wrapped in a function expression so a top-level return statement produces the invocation output. The wrapper shifts reported line numbers by one.

func DiagnoseRoutes

func DiagnoseRoutes(ctx context.Context, db orm.DB) (*integration.RouteDiagnostics, error)

DiagnoseRoutes analyses the routing table against contracts, systems, and adapters, reporting the configuration gaps that would otherwise surface only as runtime errors. Disabled routes are skipped — they are intentionally off. Definitions are config-scale, so the analysis loads them wholesale and walks them in memory.

func MaskDataSource

MaskDataSource returns a copy of ds with a non-empty password replaced by MaskedSecret, for management API responses.

func MaskInboundAuth

func MaskInboundAuth(scheme secretScheme, auth *integration.InboundAuthConfig) *integration.InboundAuthConfig

MaskInboundAuth returns a copy of auth with every non-empty sensitive parameter value replaced by MaskedSecret, for management API responses. A nil scheme (no longer registered) masks every parameter — fail closed.

func MaskOutboundAuth

func MaskOutboundAuth(scheme secretScheme, auth *integration.OutboundAuthConfig) *integration.OutboundAuthConfig

MaskOutboundAuth returns a copy of auth with every non-empty sensitive parameter value replaced by MaskedSecret, for management API responses. A nil scheme (no longer registered) masks every parameter — fail closed. The signing script is code, not a secret; it passes through.

func SensitiveValues

func SensitiveValues(declared []string, params map[string]string) []string

SensitiveValues returns the non-empty values of the parameters declared sensitive (SensitiveAll selecting every parameter). Wire captures scrub these values so a credential never lands in the invocation log or dry-run trace under whatever header or query name a scheme carries it — the point masking by a fixed name set cannot reach.

func ValidateAdapterScript

func ValidateAdapterScript(script string) error

ValidateAdapterScript rejects an adapter whose script does not compile.

func ValidateContract

func ValidateContract(contract *integration.Contract) error

ValidateContract rejects a contract whose input or output schema does not compile, so a broken schema fails at save time instead of on the first invocation.

func ValidateRouteRefs

func ValidateRouteRefs(ctx context.Context, db orm.DB, route *integration.Route) error

ValidateRouteRefs rejects a route referencing a missing contract or system. The contract reference is checked here because the column carries the empty-string wildcard sentinel and therefore has no foreign key.

func ValidateSystem

func ValidateSystem(registry OutboundAuthSchemeResolver, codec *SecretCodec, system *integration.System) error

ValidateSystem rejects a system whose base URL is not absolute or whose auth config references an unknown scheme or fails the scheme's own parameter validation. Auth params must already be in their persisted form (EncryptOutboundAuth applied) so masked placeholders have been resolved.

Types

type OutboundAuthSchemeResolver

type OutboundAuthSchemeResolver interface {
	// Resolve returns the scheme for cfg, ok=false for an unknown name.
	Resolve(cfg *integration.OutboundAuthConfig) (integration.OutboundAuthScheme, bool)
}

OutboundAuthSchemeResolver is the validator's view of the outbound scheme registry; keeping it consumer-side avoids an import cycle with the auth package.

type ProgramCache

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

ProgramCache caches compiled scripts keyed by content hash, so editing a script invalidates its entry implicitly and unchanged scripts never recompile. Each script wrapper owns an instance: adapter execution, script-scheme signing and verification, and the two envelope directions.

func NewProgramCache

func NewProgramCache(compile func(string) (*js.Program, error)) *ProgramCache

NewProgramCache creates an empty compiled-program cache backed by compile.

func (*ProgramCache) Get

func (c *ProgramCache) Get(script string) (*js.Program, error)

Get returns the compiled program for script, compiling and caching it on first sight.

type SecretCodec

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

SecretCodec encrypts sensitive auth parameter values at rest with the AES-GCM key from vef.integration.secret_key. Without a configured key it degrades to plaintext storage — NewSecretCodec logs the warning once at boot — but still refuses to load values a previous configuration encrypted.

func NewSecretCodec

func NewSecretCodec(cfg *config.IntegrationConfig) (*SecretCodec, error)

NewSecretCodec builds the codec from the configured secret key, failing fast on a malformed key.

func (*SecretCodec) DecryptDataSource

DecryptDataSource returns a copy of ds with the password decrypted, ready for the datasource registry.

func (*SecretCodec) DecryptInboundAuth

func (c *SecretCodec) DecryptInboundAuth(scheme secretScheme, auth *integration.InboundAuthConfig) (*integration.InboundAuthConfig, error)

DecryptInboundAuth returns a copy of auth with every sensitive parameter decrypted, ready to hand to InboundAuthScheme.Verify.

func (*SecretCodec) DecryptOutboundAuth

func (c *SecretCodec) DecryptOutboundAuth(scheme secretScheme, auth *integration.OutboundAuthConfig) (*integration.OutboundAuthConfig, error)

DecryptOutboundAuth returns a copy of auth with every sensitive parameter decrypted, ready to hand to OutboundAuthScheme.Apply. A nil auth decrypts to an empty config so schemes never see a nil receiver.

func (*SecretCodec) EncryptDataSource

func (c *SecretCodec) EncryptDataSource(ds, prior *integration.DataSourceConfig) error

EncryptDataSource prepares a system's data source config for persistence, mutating it in place: the password is encrypted, and a submitted MaskedSecret placeholder is replaced by the prior stored value (prior is nil on create).

func (*SecretCodec) EncryptInboundAuth

func (c *SecretCodec) EncryptInboundAuth(scheme secretScheme, auth, prior *integration.InboundAuthConfig) error

EncryptInboundAuth prepares an inbound auth config for persistence, mutating its params in place with the same masked-placeholder resolution as EncryptOutboundAuth. The verification script is code, not a secret; it stays plaintext.

func (*SecretCodec) EncryptOutboundAuth

func (c *SecretCodec) EncryptOutboundAuth(scheme secretScheme, auth, prior *integration.OutboundAuthConfig) error

EncryptOutboundAuth prepares auth for persistence, mutating its params in place: every sensitive parameter is encrypted, and a submitted MaskedSecret placeholder is replaced by the prior stored value (prior is nil on create).

Jump to

Keyboard shortcuts

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