Documentation
¶
Index ¶
- Variables
- func DecryptConfigFiles(srcDir, destDir string, key []byte, kc *Keychain) error
- func DeriveKey(password string, salt []byte) []byte
- func EncryptConfigFiles(srcDir, destDir string, key []byte, kc *Keychain) error
- func GenerateSalt() ([]byte, error)
- func ReadSaltFile(repoPath string) ([]byte, error)
- func TestConnection(repoURL, username, token string) error
- func WriteSaltFile(repoPath string, salt []byte) error
- type ConflictInfo
- type GitRepo
- func (g *GitRepo) CompareHeads(branch string) (SyncDirection, *time.Time, *time.Time, error)
- func (g *GitRepo) Fetch(username, token string) error
- func (g *GitRepo) ForcePush(username, token string) error
- func (g *GitRepo) Pull(username, token string) error
- func (g *GitRepo) Push(username, token string) error
- func (g *GitRepo) PushToBranch(branch, username, token string) error
- func (g *GitRepo) ReadRemoteFile(branch, filePath string) ([]byte, error)
- func (g *GitRepo) ResetToRemote(branch string) error
- func (g *GitRepo) StageAndCommit(msg string) (bool, error)
- type Keychain
- func (k *Keychain) Delete(key string) error
- func (k *Keychain) DeleteModelAPIKey(modelID string) error
- func (k *Keychain) DeletePassword(connID string) error
- func (k *Keychain) Get(key string) (string, error)
- func (k *Keychain) GetEncryptionKey() ([]byte, error)
- func (k *Keychain) GetGitToken() (string, error)
- func (k *Keychain) GetModelAPIKey(modelID string) (string, error)
- func (k *Keychain) GetPassword(connID string) (string, error)
- func (k *Keychain) Set(key, value string) error
- func (k *Keychain) SetGitToken(token string) error
- func (k *Keychain) SetModelAPIKey(modelID, apiKey string) error
- func (k *Keychain) SetPassword(connID, password string) error
- func (k *Keychain) StoreEncryptionKey(key []byte) error
- type SyncConfig
- type SyncConfigStore
- type SyncDirection
- type SyncResult
- type SyncService
- func (s *SyncService) ChangePassword(oldPassword, newPassword string) error
- func (s *SyncService) ConfigureRepo(repoURL, username, token, masterPassword string) (*SyncResult, error)
- func (s *SyncService) DeleteRepo() error
- func (s *SyncService) GetConfig() (SyncConfig, error)
- func (s *SyncService) IsAutoSyncEnabled() bool
- func (s *SyncService) PasswordStore() *Keychain
- func (s *SyncService) RepoPath() string
- func (s *SyncService) ResolveConflict(useLocal bool) (*SyncResult, error)
- func (s *SyncService) SaveConfig(config SyncConfig, token string) error
- func (s *SyncService) Sync() (*SyncResult, error)
- func (s *SyncService) TestConnection() error
- func (s *SyncService) VerifySyncPassword(password, username, token string) error
Constants ¶
This section is empty.
Variables ¶
var ErrWrongSyncPassword = errors.New("WRONG_SYNC_PASSWORD")
Functions ¶
func DecryptConfigFiles ¶
DecryptConfigFiles decrypts config files from srcDir into destDir. kc is used to write decrypted passwords to keychain and clear them from JSON. Pass nil for kc to skip keychain (passwords stay in JSON).
func DeriveKey ¶
DeriveKey derives a 32-byte AES-256 key from a password and salt using PBKDF2-SHA256.
func EncryptConfigFiles ¶
EncryptConfigFiles encrypts entire config files from srcDir into destDir. kc is used to backfill passwords from keychain before encryption. Pass nil for kc to skip backfill.
func GenerateSalt ¶
GenerateSalt generates a random 16-byte salt.
func ReadSaltFile ¶
ReadSaltFile reads the .sync-salt file from the repo directory. Returns nil if the file doesn't exist (new repo).
func TestConnection ¶
TestConnection verifies the repo URL is reachable.
func WriteSaltFile ¶
WriteSaltFile writes the salt to .sync-salt in the repo directory.
Types ¶
type ConflictInfo ¶
type GitRepo ¶
type GitRepo struct {
// contains filtered or unexported fields
}
func CloneOrOpen ¶
CloneOrOpen opens the repo at repoPath, or clones it from the given URL.
func (*GitRepo) CompareHeads ¶
CompareHeads returns sync direction after fetching.
func (*GitRepo) PushToBranch ¶
PushToBranch pushes the current HEAD to the specified remote branch.
func (*GitRepo) ReadRemoteFile ¶
ReadRemoteFile reads a file from the remote tracking branch without touching the worktree.
func (*GitRepo) ResetToRemote ¶
ResetToRemote resets local HEAD to match remote branch.
type Keychain ¶
type Keychain struct{}
func NewKeychain ¶
func NewKeychain() *Keychain
func (*Keychain) DeleteModelAPIKey ¶
func (*Keychain) DeletePassword ¶
func (*Keychain) GetEncryptionKey ¶
GetEncryptionKey retrieves the derived encryption key from OS keychain.
func (*Keychain) GetGitToken ¶
func (*Keychain) SetGitToken ¶
func (*Keychain) SetModelAPIKey ¶
func (*Keychain) SetPassword ¶
func (*Keychain) StoreEncryptionKey ¶
StoreEncryptionKey stores the derived encryption key in OS keychain.
type SyncConfig ¶
type SyncConfigStore ¶
type SyncConfigStore struct {
// contains filtered or unexported fields
}
func NewSyncConfigStore ¶
func NewSyncConfigStore(configDir string) *SyncConfigStore
func (*SyncConfigStore) Load ¶
func (s *SyncConfigStore) Load() (SyncConfig, error)
func (*SyncConfigStore) Save ¶
func (s *SyncConfigStore) Save(config SyncConfig) error
type SyncDirection ¶
type SyncDirection int
const ( SyncNone SyncDirection = iota SyncPush SyncPull SyncConflict )
type SyncResult ¶
type SyncResult struct {
Direction SyncDirection `json:"direction"`
Message string `json:"message"`
Conflict *ConflictInfo `json:"conflict,omitempty"`
}
type SyncService ¶
type SyncService struct {
// contains filtered or unexported fields
}
func NewSyncService ¶
func NewSyncService() (*SyncService, error)
func (*SyncService) ChangePassword ¶
func (s *SyncService) ChangePassword(oldPassword, newPassword string) error
ChangePassword re-encrypts all synced files with a new master password.
func (*SyncService) ConfigureRepo ¶
func (s *SyncService) ConfigureRepo(repoURL, username, token, masterPassword string) (*SyncResult, error)
ConfigureRepo sets up a new or existing sync repository.
func (*SyncService) DeleteRepo ¶
func (s *SyncService) DeleteRepo() error
DeleteRepo removes the local sync repo and credentials.
func (*SyncService) GetConfig ¶
func (s *SyncService) GetConfig() (SyncConfig, error)
GetConfig returns the current sync configuration.
func (*SyncService) IsAutoSyncEnabled ¶
func (s *SyncService) IsAutoSyncEnabled() bool
IsAutoSyncEnabled returns whether auto sync is enabled and configured.
func (*SyncService) PasswordStore ¶
func (s *SyncService) PasswordStore() *Keychain
PasswordStore returns the keychain as a PasswordStore for connection store integration.
func (*SyncService) RepoPath ¶
func (s *SyncService) RepoPath() string
RepoPath returns the local git repo path.
func (*SyncService) ResolveConflict ¶
func (s *SyncService) ResolveConflict(useLocal bool) (*SyncResult, error)
ResolveConflict handles a conflict by forcing push or reset.
func (*SyncService) SaveConfig ¶
func (s *SyncService) SaveConfig(config SyncConfig, token string) error
SaveConfig persists sync configuration and stores the token if provided.
func (*SyncService) Sync ¶
func (s *SyncService) Sync() (*SyncResult, error)
Sync runs a full sync cycle: clone/open → encrypt → commit → fetch → compare → push/pull → decrypt.
func (*SyncService) TestConnection ¶
func (s *SyncService) TestConnection() error
TestConnection verifies the repo is reachable with stored credentials.
func (*SyncService) VerifySyncPassword ¶
func (s *SyncService) VerifySyncPassword(password, username, token string) error
VerifySyncPassword validates credentials against the remote and verifies the password can decrypt the remote config. username and token are the new values from the form; token may be empty to keep the stored one.