Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) DeleteWithAuth(ctx context.Context, path string) (*Response, error)
- func (c *Client) Get(ctx context.Context, path string) (*Response, error)
- func (c *Client) GetWithAuth(ctx context.Context, path string) (*Response, error)
- func (c *Client) PostJSON(ctx context.Context, path string, body any) (*Response, error)
- func (c *Client) PostJSONWithAuth(ctx context.Context, path string, body any) (*Response, error)
- func (c *Client) PostMultipart(ctx context.Context, path string, body io.Reader, contentType string) (*Response, error)
- func (c *Client) RevokeAllRefreshTokens() error
- func (c *Client) RevokeRefreshToken(refreshToken string) error
- func (c *Client) SetAuth(token string)
- func (c *Client) SetDebug(enabled bool)
- func (c *Client) SetDryRun(enabled bool)
- func (c *Client) SetDryRunOutput(w io.Writer)
- func (c *Client) SetOrg(orgID string)
- func (c *Client) Token(ctx context.Context) (string, error)
- func (c *Client) UploadFile(ctx context.Context, path, filePath string) (*Response, error)
- func (c *Client) ValidateAuth(ctx context.Context) error
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrRefreshTokenRejected = errors.New("refresh token rejected; please run 'taufinity auth login'")
ErrRefreshTokenRejected is returned by refreshToken when the server definitively rejects the refresh token (HTTP 401) — it is invalid, expired, or revoked. This is the ONLY condition under which getToken deletes the stored credentials and forces a re-login. Transient failures (network errors, 5xx) return a different (wrapped) error so credentials survive and the next invocation can retry.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Taufinity API client with retry/backoff and auth support.
func (*Client) DeleteWithAuth ¶
DeleteWithAuth performs an authenticated DELETE request.
func (*Client) GetWithAuth ¶
GetWithAuth performs an authenticated GET request.
func (*Client) PostJSONWithAuth ¶
PostJSONWithAuth performs an authenticated POST request with JSON body.
func (*Client) PostMultipart ¶
func (c *Client) PostMultipart(ctx context.Context, path string, body io.Reader, contentType string) (*Response, error)
PostMultipart performs an authenticated POST request with multipart form data.
func (*Client) RevokeAllRefreshTokens ¶ added in v0.4.0
RevokeAllRefreshTokens revokes ALL of the authenticated user's CLI sessions ("log out everywhere"). Uses normal auth — getToken() auto-refreshes the access token first if it has expired, so this works after a long gap too.
func (*Client) RevokeRefreshToken ¶ added in v0.4.0
RevokeRefreshToken revokes a single CLI refresh token server-side (logout). Unauthenticated: possession of the refresh token is the authorization. The refresh token travels in the body, so this works even when the access token has already expired. Best-effort — callers may ignore network errors.
func (*Client) SetDebug ¶
SetDebug enables or disables debug request logging via a structured slog logger. When enabled, all HTTP requests and non-2xx responses are logged to stderr at Debug level.
func (*Client) SetDryRun ¶
SetDryRun enables or disables dry-run mode. In dry-run mode, non-GET requests are logged but not executed.
func (*Client) SetDryRunOutput ¶
SetDryRunOutput sets the writer for dry-run output.
func (*Client) Token ¶ added in v0.4.0
Token returns a usable access token, renewing it from the refresh token when it is expired or near expiry. This is the single public entry point for any "give me a usable access token" need (auth token, MCP config writers, the stdio bridge): it routes through the same renewing path as the authenticated request helpers, so every caller gets fresh, rotated tokens.
The ctx bounds the renewal HTTP call (including retry backoff), so a caller can cancel a slow refresh.
func (*Client) UploadFile ¶
UploadFile performs a multipart file upload.
func (*Client) ValidateAuth ¶
ValidateAuth checks that a usable access token can be produced, renewing it from the refresh token if it is expired or near expiry. Call this before starting work to fail fast on auth issues.
It is a thin wrapper over the single renewing token path (getToken/Token): renewal — and the delete-on-definitive-401 behavior — lives in exactly one place. A still-valid (not near-expiry) token passes without a server round trip; a genuinely revoked token surfaces as a 401 on the first real request.