syncclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 27 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 SaveCredentials

func SaveCredentials(remote string, credentials Credentials) error

func SaveToken

func SaveToken(remote, token string) error

Types

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 LoadCipher

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

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) (int, int, 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 {
	Endpoint  string `json:"endpoint"`
	Remote    string `json:"remote"`
	Mode      string `json:"mode"`
	ClientID  string `json:"client_id,omitempty"`
	GitHubApp bool   `json:"github_app,omitempty"`
}

func (Config) Validate

func (cfg Config) Validate() error

type Credentials

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

func LoadCredentials

func LoadCredentials(remote string) (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 OAuth

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

func (OAuth) Refresh

func (o OAuth) Refresh(ctx context.Context, clientID 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 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