refresh

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package refresh is keryx's token-refresh seam (spec 0010): a Refresher per platform plus a name-keyed registry, mirroring pkg/publish. Each platform adapter registers a Refresher that rotates/refreshes its token where it can and reports a Status (incl. an Alert + a re-auth deadline) where it can't. The `auth refresh` command fans out across the enabled platforms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Has

func Has(name string) bool

Has reports whether a platform has a registered refresher.

func ParseRFC3339

func ParseRFC3339(s string) time.Time

ParseRFC3339 parses an RFC3339 timestamp, returning the zero time on error (a missing/unparseable expiry → "unknown").

func Register

func Register(name string, c Constructor)

Register adds a platform refresher. Called from an adapter package's init().

func Registered

func Registered() []string

Registered returns the names of all compiled-in refreshers.

Types

type Action

type Action string

Action is what a Refresh did (or, in dry-run, would do).

const (
	ActionRotated   Action = "rotated"         // exchanged for a new (rotated) token, persisted
	ActionRefreshed Action = "refreshed"       // refreshed-in-place / minted, persisted
	ActionHealthy   Action = "healthy"         // token validated, nothing to persist
	ActionReauth    Action = "reauth-required" // can't refresh; interactive re-auth needed
	ActionSkipped   Action = "skipped"         // nothing to do (e.g. not near expiry)
)

type Constructor

type Constructor func(stores publish.Stores, wb oauth.WriteBack) (Refresher, error)

Constructor builds a Refresher from the config Store (it both reads current token/expiry via the Store's View and persists rotations via Apply) + the chosen write-back backend. Constructor builds a Refresher. It receives BOTH stores (spec 0042 §3.4): stores.Config for the platform wiring it reads, stores.Credentials() for any token it rotates. The unattended refresh path is exactly where a credential must not follow config routing into a committable project file.

type Refresher

type Refresher interface {
	Name() string
	Refresh(ctx context.Context, dryRun bool) (Status, error)
}

Refresher refreshes/rotates one platform's tokens (or reports it cannot).

func Resolve

func Resolve(stores publish.Stores, wb oauth.WriteBack, name string) (Refresher, error)

Resolve constructs the named platform's refresher.

type Status

type Status struct {
	Platform  string
	Action    Action
	ExpiresAt time.Time // usable-/refresh-token expiry (zero if unknown)
	ReauthBy  time.Time // when interactive re-auth becomes necessary (non-refreshable)
	Alert     bool      // surfaced to the notifier + a non-zero exit
	Detail    string
}

Status reports a platform's token health after a Refresh.

Jump to

Keyboard shortcuts

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