commands

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// execution modes
	ModeOpenSSL = "openssl"
	ModeCrypto  = "crypto"
	ModeAuto    = "auto"

	// serialization formats
	FormatJson = "json"
	FormatYaml = "yaml"
)

Variables

View Source
var (

	// ContractEncrypterFromContext returns a [SVIOE.ContractEncrypter] based on a [cli.Context]
	ContractEncrypterFromContext = F.Flow2(
		EncryptAndSignConfigFromContext,
		ContractEncrypterFromConfig,
	)

	// ValidatedContractFromContext returns a [types.Contract] from a [cli.Context] and validates it against the schema
	ValidatedContractFromContext = F.Flow3(
		lookupInput,
		CFIOE.ReadFromInput,
		IOE.ChainEitherK(F.Flow2(
			Y.Parse[types.AnyMap],
			E.Chain(types.ValidateContract),
		)),
	)

	// EncryptAndSignFromContext returns an [SC.EncryptedContract] from information on the [cli.Context]
	EncryptAndSignFromContext = F.Flow4(
		T.Replicate2[*cli.Context],
		T.Map2(ContractEncrypterFromContext, ValidatedContractFromContext),
		T.Tupled2(IOE.MonadAp[IOE.IOEither[error, SC.EncryptedContract], error, *types.Contract]),
		IOE.Flatten[error, SC.EncryptedContract],
	)

	// EncryptSignAndWriteFromContext transforms an unencrypted contract into an encrypted and signed contract from information on the [cli.Context]
	EncryptSignAndWriteFromContext = F.Flow3(
		T.Replicate2[*cli.Context],
		T.Map2(EncryptAndSignFromContext, writeFromContext[SC.EncryptedContract]),
		T.Tupled2(IOE.MonadChain[error, SC.EncryptedContract, []byte]),
	)

	DownloadCertificatesFromContext = F.Flow2(
		DownloadCertificatesConfigFromContext,
		DownloadCertificatesFromConfig,
	)

	DownloadCertificatesAndWriteFromContext = F.Flow3(
		T.Replicate2[*cli.Context],
		T.Map2(DownloadCertificatesFromContext, writeFromContext[map[string]string]),
		T.Tupled2(IOE.MonadChain[error, map[string]string, []byte]),
	)
)

Functions

func Commands

func Commands() []*cli.Command

Commands returns the array of supported commands

func ContractEncrypterFromConfig

func ContractEncrypterFromConfig(cfg *EncryptAndSignConfig) IOE.IOEither[error, SVIOE.ContractEncrypter]

ContractEncrypterFromConfig constructs a [SVIOE.ContractEncrypter] based on a config object

func DownloadCertificatesCommand

func DownloadCertificatesCommand() *cli.Command

EncryptAndSignCommand returns a command that encrypts and signs a contract

func DownloadCertificatesFromConfig

func DownloadCertificatesFromConfig(cfg *DownloadCertificatesConfig) IOE.IOEither[error, map[string]string]

DownloadCertificatesFromConfig dowloads certificates based on some config

func EncryptAndSignCommand

func EncryptAndSignCommand() *cli.Command

EncryptAndSignCommand returns a command that encrypts and signs a contract

Types

type DownloadCertificatesConfig

type DownloadCertificatesConfig struct {
	Versions    []string // possible versions to download
	UrlTemplate string   // the URL template for the download URL
}

func DownloadCertificatesConfigFromContext

func DownloadCertificatesConfigFromContext(ctx *cli.Context) *DownloadCertificatesConfig

DownloadCertificatesConfigFromContext decodes the DownloadCertificatesConfig from a cli.Context

type EncryptAndSignConfig

type EncryptAndSignConfig struct {
	Mode    string    // one of the mode flags
	PrivKey KeyConfig // private key used for signing
	PubCert KeyConfig // public key used for encryption
}

func EncryptAndSignConfigFromContext

func EncryptAndSignConfigFromContext(ctx *cli.Context) *EncryptAndSignConfig

EncryptAndSignConfigFromContext decodes an EncryptAndSignConfig from a cli.Context

type KeyConfig

type KeyConfig struct {
	FromDirect O.Option[string] // key as a PEM encoded string
	FromFile   O.Option[string] // filename to a PEM encoded key
}

type OutputConfig

type OutputConfig struct {
	Format string // output format (e.g. json, or yaml)
	Output string // target of the output (e.g. a filename, or stdout)
}

OutputConfig specifies aspects of the output

func OutputConfigFromContext

func OutputConfigFromContext(ctx *cli.Context) *OutputConfig

OutputConfigFromContext returns an OutputConfig based on the cli.Context

Jump to

Keyboard shortcuts

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