common

package
v0.0.0-...-b105f1e Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TLSSystemCertPoolFlagName defines the flag for the system certificate pool.
	TLSSystemCertPoolFlagName = "tls-systemcertpool"
	// TLSSystemCertPoolFlagUsage defines the usage of the system certificate pool flag.
	TLSSystemCertPoolFlagUsage = "Use system certificate pool." +
		" Possible values [true] [false]. Defaults to false if not set." +
		" Alternatively, this can be set with the following environment variable: " + TLSSystemCertPoolEnvKey
	// TLSSystemCertPoolEnvKey defines the environment variable for the system certificate pool flag.
	TLSSystemCertPoolEnvKey = "ORB_CLI_TLS_SYSTEMCERTPOOL"

	// TLSCACertsFlagName defines the flag for the CA certs flag.
	TLSCACertsFlagName = "tls-cacerts"
	// TLSCACertsFlagUsage defines the usage of the CA certs flag.
	TLSCACertsFlagUsage = "Comma-separated list of ca certs path." +
		" Alternatively, this can be set with the following environment variable: " + TLSCACertsEnvKey
	// TLSCACertsEnvKey defines the environment variable for the CA certs flag.
	TLSCACertsEnvKey = "ORB_CLI_TLS_CACERTS"

	// AuthTokenFlagName defines the flag for the authorization bearer token.
	AuthTokenFlagName = "auth-token"
	// AuthTokenFlagUsage defines the usage of the authorization bearer token flag.
	AuthTokenFlagUsage = "Auth token." +
		" Alternatively, this can be set with the following environment variable: " + AuthTokenEnvKey
	// AuthTokenEnvKey defines the environment variable for the authorization bearer token flag.
	AuthTokenEnvKey = "ORB_CLI_AUTH_TOKEN" //nolint:gosec

	// TargetOverrideFlagName defines the flag for specifying target overrides.
	TargetOverrideFlagName = "target-override"
	// TargetOverrideFlagUsage defines the flag for target override usage.
	TargetOverrideFlagUsage = "Overrides one or more targets used for resolving HTTP endpoints. " +
		" For example, --target-override orb.domain2.com->localhost:48426 will use localhost:48426 instead of" +
		" orb.domain2.com for HTTP requests. This flag should only be used for testing." +
		" Alternatively, this can be set with the following environment variable: " + TargetOverrideEnvKey
	// TargetOverrideEnvKey defines the flag for target override environment variable.
	TargetOverrideEnvKey = "ORB_CLI_OUTBOX_URL"
)

Variables

This section is empty.

Functions

func AddCommonFlags

func AddCommonFlags(cmd *cobra.Command)

AddCommonFlags adds common flags to the given command.

func GetDuration

func GetDuration(cmd *cobra.Command, flagName, envKey string,
	defaultDuration time.Duration,
) (time.Duration, error)

GetDuration get duration.

func GetKey

func GetKey(cmd *cobra.Command, keyFlagName, keyEnvKey, keyFileFlagName, keyFileEnvKey string,
	password []byte, privateKey bool,
) (interface{}, error)

GetKey get key.

func GetPublicKeyFromKMS

func GetPublicKeyFromKMS(cmd *cobra.Command, keyIDFlagName, keyIDEnvKey string,
	webKmsClient kms.KeyManager,
) (interface{}, error)

GetPublicKeyFromKMS get publickey from kms.

func GetServices

func GetServices(serviceFilePath string) ([]docdid.Service, error)

GetServices get services.

func GetVDRPublicKeysFromFile

func GetVDRPublicKeysFromFile(publicKeyFilePath string) (*docdid.Doc, error)

GetVDRPublicKeysFromFile get public keys from file.

func NewHTTPClient

func NewHTTPClient(cmd *cobra.Command) (*http.Client, error)

NewHTTPClient returns a new HTTP client using the arguments from the given command.

func ParsePrivateKey

func ParsePrivateKey(der []byte) (crypto.PrivateKey, error)

ParsePrivateKey parse private key.

func Printf

func Printf(out io.Writer, msg string, args ...interface{})

Printf prints to the given writer.

func Println

func Println(out io.Writer, msg string)

Println prints a line to the given writer.

func PrivateKeyFromFile

func PrivateKeyFromFile(file string, password []byte) (crypto.PrivateKey, error)

PrivateKeyFromFile private key from file.

func PrivateKeyFromPEM

func PrivateKeyFromPEM(privateKeyPEM, password []byte) (crypto.PrivateKey, error)

PrivateKeyFromPEM private key pem.

func PublicKeyFromFile

func PublicKeyFromFile(file string) (crypto.PublicKey, error)

PublicKeyFromFile public key from file.

func PublicKeyFromPEM

func PublicKeyFromPEM(pubKeyPEM []byte) (crypto.PublicKey, error)

PublicKeyFromPEM public key from pem.

func SendHTTPRequest

func SendHTTPRequest(cmd *cobra.Command, reqBytes []byte, method, endpointURL string) ([]byte, error)

SendHTTPRequest sends the given HTTP request using the options provided on the command-line.

func SendRequest

func SendRequest(httpClient *http.Client, req []byte, headers map[string]string, method,
	endpointURL string,
) ([]byte, error)

SendRequest send http request.

Types

type ActivityPubClient

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

ActivityPubClient reads ActivityPub actors and collections from the service endpoint.

func NewActivityPubClient

func NewActivityPubClient(cmd *cobra.Command) (*ActivityPubClient, error)

NewActivityPubClient returns a new ActivityPub client.

func (*ActivityPubClient) CollectionContains

func (c *ActivityPubClient) CollectionContains(collURI *url.URL, iri string) (bool, error)

CollectionContains returns true if the given ActivityPub collection contains the given IRI.

func (*ActivityPubClient) GetCollection

func (c *ActivityPubClient) GetCollection(collURI *url.URL) (*ActivityPubCollectionIterator, error)

GetCollection returns an ActivityPub collection iterator for the given collection IRI.

func (*ActivityPubClient) ResolveActor

func (c *ActivityPubClient) ResolveActor(actorEndpoint string) (*vocab.ActorType, error)

ResolveActor returns the actor for the given endpoint.

type ActivityPubCollectionIterator

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

ActivityPubCollectionIterator iterates over an ActivityPub collection.

func (*ActivityPubCollectionIterator) Next

func (it *ActivityPubCollectionIterator) Next() (*url.URL, error)

Next returns the next item in the collection.

type PublicKey

type PublicKey struct {
	ID       string   `json:"id,omitempty"`
	Type     string   `json:"type,omitempty"`
	Purposes []string `json:"purposes,omitempty"`
	JWKPath  string   `json:"jwkPath,omitempty"`
	B58Key   string   `json:"b58Key,omitempty"`
}

PublicKey struct.

type Signer

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

Signer operation.

func NewSigner

func NewSigner(signingkey crypto.PrivateKey, signingKeyID string, webKmsCryptoClient webcrypto.Crypto,
	signingKeyPK crypto.PublicKey,
) *Signer

NewSigner return new signer.

func (*Signer) Headers

func (s *Signer) Headers() jws.Headers

Headers return headers.

func (*Signer) PublicKeyJWK

func (s *Signer) PublicKeyJWK() *jws.JWK

PublicKeyJWK return public key JWK.

func (*Signer) Sign

func (s *Signer) Sign(data []byte) ([]byte, error)

Sign data.

Jump to

Keyboard shortcuts

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