client

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package client provides an HTTP client for the pulse server API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ServerURL string
	// contains filtered or unexported fields
}

Client is an HTTP client for the pulse server.

func New

func New(serverURL string) *Client

New creates a new pulse client for the given server URL.

func (*Client) EnsureToken

func (c *Client) EnsureToken() error

EnsureToken loads and refreshes the token if needed.

func (*Client) LoadToken

func (c *Client) LoadToken() error

LoadToken reads the saved authentication token from disk.

func (*Client) RefreshToken

func (c *Client) RefreshToken() error

RefreshToken exchanges the current token for a new one.

func (*Client) SaveToken

func (c *Client) SaveToken(token string, expiresAt time.Time) error

SaveToken persists the authentication token to disk.

func (*Client) SendPulse

func (c *Client) SendPulse(count int64, hostname string) error

SendPulse submits a keystroke count to the server.

func (*Client) ShouldRefresh

func (c *Client) ShouldRefresh() bool

ShouldRefresh reports whether the token needs refreshing.

func (*Client) Token

func (c *Client) Token() string

Token returns the current authentication token string.

type TokenData

type TokenData struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
	SavedAt   time.Time `json:"saved_at"`
}

TokenData holds authentication token data with expiration info.

Jump to

Keyboard shortcuts

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