bridge

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IdentityFileName = "identity"
	HostIDFileName   = "host-id"
	TrustedDirName   = "trusted"
)
View Source
const EnvelopeVersion = 1

Variables

This section is empty.

Functions

func CanonicalBytes

func CanonicalBytes(env Envelope) []byte

func DestSidecarPath

func DestSidecarPath(messagePath string) string

DestSidecarPath is the sibling dest-binding file for a spool message.

func HostIDPath

func HostIDPath(root string) string

func IdentityPath

func IdentityPath(root string) string

func LoadHostID

func LoadHostID(root string) (string, error)

func LoadHostIDFromDeliveryRoot

func LoadHostIDFromDeliveryRoot(root *fsq.DeliveryRoot) (string, error)

LoadHostIDFromDeliveryRoot reads host-id through an already-authorized delivery-root capability so the identity used for routing cannot be replaced through the ambient root path after authorization.

func LoadTrusted

func LoadTrusted(root, host string) (ed25519.PublicKey, string, error)

func LoadTrustedFromDeliveryRoot

func LoadTrustedFromDeliveryRoot(root *fsq.DeliveryRoot, host string) (ed25519.PublicKey, string, error)

LoadTrustedFromDeliveryRoot reads a trusted public key through an already-authorized delivery-root capability. The source host remains an envelope claim until this exact trusted file is loaded and signature verification succeeds.

func MarshalEnvelope

func MarshalEnvelope(env Envelope) ([]byte, error)

func ParseAlias

func ParseAlias(alias string) (host, agent string, err error)

func SignEnvelope

func SignEnvelope(env *Envelope, key HostKey) error

func TransferFilename

func TransferFilename(sourceHost, transferID string) string

func TrustedPath

func TrustedPath(root, host string) string

func ValidateEnqueueConfig

func ValidateEnqueueConfig(cfg EnqueueConfig) error

ValidateEnqueueConfig checks the decoded enqueue configuration.

func ValidateEnvelope

func ValidateEnvelope(env Envelope) error

func VerifyEnvelope

func VerifyEnvelope(env Envelope, pub ed25519.PublicKey, generation string) error

func WriteHostID

func WriteHostID(root, host string) error

func WriteIdentity

func WriteIdentity(root string, key HostKey) error

func WriteTrusted

func WriteTrusted(root, host string, pub ed25519.PublicKey, generation string) error

Types

type ApplyResult

type ApplyResult struct {
	Path     string
	Replayed bool
}

ApplyResult is the durable local outcome of one envelope.

func ApplyEnvelope

func ApplyEnvelope(root *fsq.DeliveryRoot, localHost, localAgent string, env Envelope) (ApplyResult, error)

ApplyEnvelope commits the payload into the local agent's inbox under a stable transfer filename keyed by (source_host, transfer_id). The same digest is idempotent; a different digest for that key is a conflict.

type EnqueueConfig

type EnqueueConfig struct {
	Root               string   `json:"root"`
	SourceHost         string   `json:"source_host"`
	SourceHandle       string   `json:"source_handle"`
	AllowedDestAliases []string `json:"allowed_dest_aliases"`
}

EnqueueConfig is the audited Bot-side bridge enqueue configuration.

func LoadEnqueueConfig

func LoadEnqueueConfig(path string) (EnqueueConfig, error)

LoadEnqueueConfig reads and validates a private mode-0600 enqueue config file.

func (EnqueueConfig) AllowedDestSet

func (cfg EnqueueConfig) AllowedDestSet() map[string]struct{}

AllowedDestSet returns the configured destination aliases as a lookup set.

type EnqueueResult

type EnqueueResult struct {
	Path     string
	Filename string
}

EnqueueResult is the durable local outcome of one bridge enqueue.

func Enqueue

func Enqueue(cfg EnqueueConfig, destAlias string, message []byte) (EnqueueResult, error)

Enqueue writes one complete AMQ message into the bridge outbound spool.

type Envelope

type Envelope struct {
	Version         int    `json:"version"`
	TransferID      string `json:"transfer_id"`
	SourceHost      string `json:"source_host"`
	SourceHandle    string `json:"source_handle"`
	DestAlias       string `json:"dest_alias"`
	SourceMessageID string `json:"source_message_id"`
	ThreadID        string `json:"thread_id"`
	PayloadSHA256   string `json:"payload_sha256"`
	KeyGeneration   string `json:"key_generation"`
	Signature       string `json:"signature"`
	Payload         []byte `json:"payload"`
}

Envelope is the v1 amq-bridge wire unit. Extra JSON fields are rejected.

func UnmarshalEnvelope

func UnmarshalEnvelope(raw []byte) (Envelope, error)

type HostKey

type HostKey struct {
	Generation string
	Private    ed25519.PrivateKey
}

HostKey is one Ed25519 generation for a bridge host principal.

func GenerateHostKey

func GenerateHostKey(generation string) (HostKey, error)

func LoadIdentity

func LoadIdentity(root string) (HostKey, error)

func (HostKey) Public

func (k HostKey) Public() ed25519.PublicKey

Jump to

Keyboard shortcuts

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