Documentation
¶
Index ¶
Constants ¶
const ( Uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Lowercase = "abcdefghijklmnopqrstuvwxyz" Digits = "0123456789" Symbols = "~!@#%&*_-+=,.<>?" )
Variables ¶
var ( // List of possible errors returned by the SecretBin API. ErrInvalidExpirationTime = &SecretBinError{Name: "InvalidExpirationTime"} ErrSecretNotFound = &SecretBinError{Name: "SecretNotFoundError"} ErrSecretAlreadyExists = &SecretBinError{Name: "SecretAlreadyExistsError"} ErrSecretList = &SecretBinError{Name: "SecretListError"} ErrSecretRead = &SecretBinError{Name: "SecretReadError"} ErrSecretCreate = &SecretBinError{Name: "SecretCreateError"} ErrSecretUpdate = &SecretBinError{Name: "SecretUpdateError"} ErrSecretDelete = &SecretBinError{Name: "SecretDeleteError"} ErrSecretParse = &SecretBinError{Name: "SecretParseError"} ErrSecretPolicy = &SecretBinError{Name: "SecretPolicyError"} ErrSecretSizeLimit = &SecretBinError{Name: "SecretSizeLimitError"} )
var ( ErrInvalidPasswordLength = errors.New("invalid password length; must be greater than 6") ErrInvalidCharacterSet = errors.New( "at least one character set (uppercase, lowercase, digits, symbols) must be selected") )
Functions ¶
func GeneratePassword ¶ added in v2.1.0
func GeneratePassword(options PasswordOptions) (string, error)
GeneratePassword generates a secure random password based on the provided options. It ensures that at least one character from each selected set is included. If no character sets are selected or the length is below 6, it returns an error.
Types ¶
type Attachment ¶
type Client ¶
type Config ¶
type Config struct {
Name string // Name of the SecretBin instance
Endpoint string // Endpoint URL of the SecretBin server
Version *semver.Version // Version of the SecretBin server
Banner *Banner // Optional banner displayed by the server
Expires map[string]Expires // Available expiration options for secrets
DefaultExpires string // Default expiration option for secrets
}
func (*Config) ExpireOptionsSorted ¶
ExpiresOptionsSorted returns a slice of expiration option names sorted by their duration.
type Expires ¶
type Options ¶
type Options struct {
// Password is used as an additional security step along the the encryption key (optional)
Password string
// Expires is the expiration time for the secret.
//
// Use [Client.Config().Expires] to get the available options.
Expires string
// BurnAfter indicates after how many reads the secret should be deleted.
//
// 0 means no burn after reading.
BurnAfter uint
}
type PasswordOptions ¶ added in v2.1.0
PasswordOptions defines the options for generating a password.
type Secret ¶
type Secret struct {
Message string `json:"message"` // Text content of the secret
Attachments []*Attachment `json:"attachments"` // Optional file attachments of the secret
}
func (*Secret) AddAttachment ¶
AddAttachment adds an attachment to the secret content. If the content type is not provided, it will be guessed based on the file extension.
func (*Secret) AddFileAttachment ¶
AddFileAttachment reads a file from the given path and adds it as an attachment to the secret content. The content type is guessed based on the file extension.
type SecretBinError ¶
type SecretBinError struct {
Name string `json:"name"`
Message string `json:"message"`
Status int `json:"status"`
}
func (*SecretBinError) Error ¶
func (e *SecretBinError) Error() string
Error marks the SecretBinError as an error type.
func (*SecretBinError) Is ¶
func (e *SecretBinError) Is(target error) bool
Is checks if the error matches the target error.