storage

package
v0.0.0-...-2b24f7e Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext string) (string, error)

func Encrypt

func Encrypt(plaintext string) (string, error)

func HashPassword

func HashPassword(password string) string

Types

type Config

type Config struct {
	URL         string                `json:"url"`
	EndpointID  int                   `json:"endpoint_id,omitempty"`
	Credentials *EncryptedCredentials `json:"credentials,omitempty"`
	Token       *EncryptedToken       `json:"token,omitempty"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func (*Config) ClearCredentials

func (c *Config) ClearCredentials() error

func (*Config) GetCredentials

func (c *Config) GetCredentials() (string, string, string, error)

func (*Config) GetToken

func (c *Config) GetToken() (string, time.Time, error)

func (*Config) IsTokenValid

func (c *Config) IsTokenValid() bool

func (*Config) Save

func (c *Config) Save() error

func (*Config) SetCredentials

func (c *Config) SetCredentials(username, password, credType string) error

func (*Config) SetEndpoint

func (c *Config) SetEndpoint(endpointID int) error

func (*Config) SetToken

func (c *Config) SetToken(jwt string, expiresAt time.Time) error

func (*Config) SetURL

func (c *Config) SetURL(url string) error

type EncryptedCredentials

type EncryptedCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"` // Encrypted
	Type     string `json:"type"`     // "password" or "code"
}

type EncryptedToken

type EncryptedToken struct {
	JWT       string    `json:"jwt"` // Encrypted
	ExpiresAt time.Time `json:"expires_at"`
	Refresh   string    `json:"refresh,omitempty"` // Encrypted refresh token if available
}

Jump to

Keyboard shortcuts

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