rpc

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: CC0-1.0 Imports: 13 Imported by: 0

Documentation

Overview

Package rpc loads the saved auth.json and constructs Connect clients that automatically attach the Bearer token. Every CLI command that talks to prosa-server goes through here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Analytics

func Analytics(server, token string) prosav1connect.AnalyticsServiceClient

func Auth

Auth returns an AuthServiceClient (no auth file required; the auth RPCs are public).

func ConnectError

func ConnectError(err error) string

ConnectError unwraps connect.Error for display.

func ContextOrBackground

func ContextOrBackground(ctx context.Context) context.Context

func DeleteAuth

func DeleteAuth() error

DeleteAuth removes auth.json. No-op when the file doesn't exist.

func Devices

func Devices(server, token string) prosav1connect.DevicesServiceClient

func NormalizeServerURL

func NormalizeServerURL(in string) string

NormalizeServerURL turns ":7070" into "http://localhost:7070" and strips trailing slashes.

func SaveAuth

func SaveAuth(f AuthFile) error

SaveAuth atomically writes the file with 0600 permissions.

func Sessions

func Sessions(server, token string) prosav1connect.SessionsServiceClient

Sessions / Devices clients pull token from the loaded auth file. If the file is missing the caller gets an error so the command can suggest `prosa login`.

Types

type AuthFile

type AuthFile struct {
	Server   string `json:"server"`
	DeviceID string `json:"device_id"`
	Token    string `json:"token"`
}

AuthFile is the on-disk shape stored at paths.AuthPath().

func LoadAuth

func LoadAuth() (AuthFile, error)

LoadAuth reads the saved auth file. Returns os.ErrNotExist when the file is missing — callers can treat that as "not logged in".

Jump to

Keyboard shortcuts

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