syncclient

package
v1.1.0-solo.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadToken

func LoadToken(remote string) (string, error)

func RecordAttempt

func RecordAttempt(dir string, cfg Config, attemptErr error) error

func SaveCredentials

func SaveCredentials(remote string, credentials Credentials) error

func SaveToken

func SaveToken(remote, token string) error

Types

type BrowserCode

type BrowserCode struct {
	State       string
	Verifier    string
	Challenge   string
	RedirectURI string
	AuthURL     string
}

type Cipher

type Cipher struct {
	Salt []byte
	// contains filtered or unexported fields
}

Cipher holds a key derived on this device. Only its random salt may be shared.

func Derive

func Derive(passphrase string, salt []byte) (*Cipher, error)

func FromKey

func FromKey(encoded string, salt []byte) (*Cipher, error)

FromKey restores a cipher whose key was saved in the operating system credential store. The salt remains in the repository's .trace directory.

func LoadCipher

func LoadCipher(traceDir, passphrase string) (*Cipher, error)

func (*Cipher) KeyForCredentialStore

func (c *Cipher) KeyForCredentialStore() string

func (*Cipher) Open

func (c *Cipher) Open(encoded, aad string) ([]byte, error)

func (*Cipher) Seal

func (c *Cipher) Seal(plain []byte, aad string) (string, error)

type Client

type Client struct {
	HTTP          *http.Client
	Config        Config
	Token         string
	TokenProvider func(context.Context) (string, error)
	Cipher        *Cipher
	TraceDir      string
	DB            *sql.DB
	Blobs         *blob.Store
}

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, traceDir, passphrase string) (int, int, error)

Pull creates a new Trace history in an existing Git checkout. It never replaces an existing .trace directory or changes working-tree files.

func (*Client) Sync

func (c *Client) Sync(ctx context.Context) (blobTotal int, rowTotal int, resultErr error)

Sync uploads content-addressed blobs first, then append-only rows. Each row batch advances its local cursor only after the server acknowledges the request.

type Config

type Config struct {
	ConnectionExpiresAt int64  `json:"connection_expires_at,omitempty"`
	ConnectionID        string `json:"connection_id,omitempty"`
	Endpoint            string `json:"endpoint"`
	Remote              string `json:"remote"`
	Mode                string `json:"mode"`
	ClientID            string `json:"client_id,omitempty"`
	GitHubApp           bool   `json:"github_app,omitempty"`
	BrokerRefresh       bool   `json:"broker_refresh,omitempty"`
	AutoSync            bool   `json:"auto_sync,omitempty"`
}

func (Config) CredentialKey

func (cfg Config) CredentialKey() string

CredentialKey keeps account-scoped connections separate from GitHub login credentials and from connections to another Trace server.

func (Config) Validate

func (cfg Config) Validate() error

type Credentials

type Credentials struct {
	ConnectionID     string `json:"connection_id,omitempty"`
	AccessToken      string `json:"access_token"`
	RefreshToken     string `json:"refresh_token,omitempty"`
	ExpiresAt        int64  `json:"expires_at,omitempty"`
	RefreshExpiresAt int64  `json:"refresh_expires_at,omitempty"`
	ProSyncKey       string `json:"pro_sync_key,omitempty"`
}

func LoadConfigCredentials

func LoadConfigCredentials(cfg Config) (Credentials, error)

LoadConfigCredentials migrates only a legacy entry whose identity matches the checkout. Never infer ownership from a project label shared by two accounts.

func LoadCredentials

func LoadCredentials(remote string) (Credentials, error)

func WaitPairing

func WaitPairing(ctx context.Context, client *http.Client, endpoint string, pairing Pairing) (Credentials, error)

type DeviceCode

type DeviceCode struct {
	Code      string `json:"device_code"`
	UserCode  string `json:"user_code"`
	VerifyURL string `json:"verification_uri"`
	ExpiresIn int    `json:"expires_in"`
	Interval  int    `json:"interval"`
}

type Health

type Health struct {
	ConnectionID string `json:"connection_id,omitempty"`
	LastAttempt  int64  `json:"last_attempt"`
	LastSuccess  int64  `json:"last_success"`
	LastError    string `json:"last_error,omitempty"`
	Action       string `json:"action,omitempty"`
}

func ReadHealth

func ReadHealth(dir string) (Health, error)

type OAuth

type OAuth struct {
	Client *http.Client
	Base   string
	App    bool
}

func (OAuth) BrowserAuthorization

func (OAuth) BrowserAuthorization(clientID, redirectURI string) (BrowserCode, error)

func (OAuth) ExchangeWithPlatform

func (o OAuth) ExchangeWithPlatform(ctx context.Context, endpoint string, flow BrowserCode, code string) (Credentials, error)

func (OAuth) Refresh

func (o OAuth) Refresh(ctx context.Context, clientID string, previous Credentials) (Credentials, error)

func (OAuth) RefreshWithPlatform

func (o OAuth) RefreshWithPlatform(ctx context.Context, endpoint string, previous Credentials) (Credentials, error)

func (OAuth) Start

func (o OAuth) Start(ctx context.Context, clientID string) (DeviceCode, error)

func (OAuth) Wait

func (o OAuth) Wait(ctx context.Context, clientID string, code DeviceCode) (string, error)

func (OAuth) WaitCredentials

func (o OAuth) WaitCredentials(ctx context.Context, clientID string, code DeviceCode) (Credentials, error)

type Pairing

type Pairing struct {
	ID              string `json:"id"`
	VerificationURI string `json:"verification_uri"`
	ExpiresAt       int64  `json:"expires_at"`
	Interval        int    `json:"interval"`
	// contains filtered or unexported fields
}

func StartPairing

func StartPairing(ctx context.Context, client *http.Client, cfg Config, device string) (Pairing, error)

type Row

type Row struct {
	Table      string          `json:"table"`
	ID         string          `json:"id"`
	Data       json.RawMessage `json:"data,omitempty"`
	Ciphertext string          `json:"ciphertext,omitempty"`
	Salt       string          `json:"salt,omitempty"`
}

type State

type State struct {
	Target  string            `json:"target"`
	Cursors map[string]string `json:"cursors"`
}

Jump to

Keyboard shortcuts

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