common

package
v0.7.2-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 34 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDigest

func CalculateDigest[I any](r jsonrpc2.Request[I]) ([32]byte, error)

func DeriveBundleFilename

func DeriveBundleFilename(digest [32]byte) string

func EncryptSecret

func EncryptSecret(secret, masterPublicKeyHex string) (string, error)

func HexToBytes32

func HexToBytes32(h string) ([32]byte, error)

func SaveBundle

func SaveBundle(path string, b *UnsignedBundle) error

Types

type GatewayClient

type GatewayClient interface {
	Post(body []byte) (respBody []byte, status int, err error)
}

type HTTPClient

type HTTPClient struct {
	URL           string
	Client        *http.Client
	RetryAttempts uint
	RetryDelay    time.Duration
}

func (*HTTPClient) Post

func (g *HTTPClient) Post(body []byte) ([]byte, int, error)

type Handler

type Handler struct {
	Log             *zerolog.Logger
	ClientFactory   client.Factory
	SecretsFilePath string
	PrivateKey      *ecdsa.PrivateKey
	OwnerAddress    string
	EnvironmentSet  *environments.EnvironmentSet
	Gw              GatewayClient
}

func NewHandler

func NewHandler(ctx *runtime.Context, secretsFilePath string) (*Handler, error)

NewHandler creates a new handler instance.

func (*Handler) EncryptSecrets

func (h *Handler) EncryptSecrets(rawSecrets UpsertSecretsInputs) ([]*vault.EncryptedSecret, error)

EncryptSecrets takes the raw secrets and encrypts them, returning pointers.

func (*Handler) Execute

func (h *Handler) Execute(
	inputs UpsertSecretsInputs,
	method string,
	duration time.Duration,
	ownerType string,
) error

Execute is shared for 'create' and 'update' (YAML-only). - MSIG => step 1: build request, save bundle, print instructions - EOA => build request, allowlist if needed, POST

func (*Handler) LogMSIGNextSteps

func (h *Handler) LogMSIGNextSteps(txData string, digest [32]byte, bundlePath string) error

func (*Handler) PackAllowlistRequestTxData

func (h *Handler) PackAllowlistRequestTxData(reqDigest [32]byte, duration time.Duration) (string, error)

TODO: use TxType interface

func (*Handler) ParseVaultGatewayResponse

func (h *Handler) ParseVaultGatewayResponse(method string, respBody []byte) error

ParseVaultGatewayResponse parses the JSON-RPC response, decodes the SignedOCRResponse payload into the appropriate proto type (CreateSecretsResponse, UpdateSecretsResponse, DeleteSecretsResponse), and logs one line per secret with id/owner/namespace/success/error.

func (*Handler) ResolveInputs

func (h *Handler) ResolveInputs() (UpsertSecretsInputs, error)

ResolveInputs loads secrets from a YAML file. Errors if the path is not .yaml/.yml — MSIG step 2 is handled by `cre secrets execute`.

func (*Handler) ValidateInputs

func (h *Handler) ValidateInputs(inputs UpsertSecretsInputs) error

ValidateInputs validates the input structure.

type MockClientFactory

type MockClientFactory struct {
	mock.Mock
}

func (*MockClientFactory) GetSkipConfirmation

func (m *MockClientFactory) GetSkipConfirmation() bool

func (*MockClientFactory) GetTxType

func (m *MockClientFactory) GetTxType() client.TxType

func (*MockClientFactory) NewWorkflowRegistryV2Client

func (m *MockClientFactory) NewWorkflowRegistryV2Client() (*client.WorkflowRegistryV2Client, error)

type SecretItem

type SecretItem struct {
	ID        string `json:"id" validate:"required"`
	Value     string `json:"value" validate:"required"`
	Namespace string `json:"namespace"`
}

SecretItem represents a single secret with its ID, value, and optional namespace.

type SecretsYamlConfig

type SecretsYamlConfig struct {
	SecretsNames map[string][]string `yaml:"secretsNames"`
}

type UnsignedBundle

type UnsignedBundle struct {
	RequestID   string          `json:"request_id"`
	Method      string          `json:"method"`
	DigestHex   string          `json:"digest_hex"`
	RequestBody json.RawMessage `json:"request_body"`
	CreatedAt   time.Time       `json:"created_at"`
}

func LoadBundle

func LoadBundle(path string) (*UnsignedBundle, error)

type UpsertSecretsInputs

type UpsertSecretsInputs []SecretItem

UpsertSecretsInputs holds the secrets passed to the CLI.

Jump to

Keyboard shortcuts

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