license

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPublicKey

func InitPublicKey(key string)

Types

type EditionChangeCallback added in v1.2.12

type EditionChangeCallback func(ctx context.Context, prev, next bool)

EditionChangeCallback is invoked after the manager observes a transition in IsProEnabled. prev and next are the old and new values. The callback is invoked from a dedicated goroutine with a 30-second timeout; it must not block. RegisterEditionChangeCallback must be called before Start.

type LicensePayload

type LicensePayload struct {
	Status     string    `json:"status"`
	Plan       string    `json:"plan"`
	Features   []string  `json:"features"`
	ExpiresAt  time.Time `json:"expires_at"`
	VerifiedAt time.Time `json:"verified_at"`
	Message    string    `json:"message"`
}

LicensePayload is the decoded and verified license payload.

type Manager added in v1.2.12

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles license verification, caching, and state management.

func NewManager added in v1.2.12

func NewManager(licenseKey, dataDir, version string, logger *slog.Logger) (*Manager, error)

NewManager creates a new license manager and synchronously loads the disk cache so IsProEnabled() reflects the persisted Pro/CE state immediately. This matters because edition-gated wiring runs before Start (e.g. extension.CurrentEdition() checks during app construction). Call Start() to begin periodic verification.

func (*Manager) IsProEnabled added in v1.2.12

func (m *Manager) IsProEnabled() bool

IsProEnabled returns true if the current license enables Pro features.

func (*Manager) RegisterEditionChangeCallback added in v1.2.12

func (m *Manager) RegisterEditionChangeCallback(cb EditionChangeCallback)

RegisterEditionChangeCallback registers a callback invoked on IsProEnabled transitions. Must be called before Start to avoid missing initial transitions.

func (*Manager) Start added in v1.2.12

func (m *Manager) Start(ctx context.Context)

Start performs an initial license check, then starts a background ticker. Non-blocking: errors during the initial check are logged, not fatal. The disk cache has already been loaded by NewManager.

func (*Manager) State added in v1.2.12

func (m *Manager) State() *State

State returns the current license state (thread-safe).

func (*Manager) Stop added in v1.2.12

func (m *Manager) Stop()

Stop stops the background ticker.

type ServerError added in v1.2.1

type ServerError struct {
	HTTPStatus int
	Status     string
	Message    string
}

ServerError is returned by fetchLicense when the server responds with a non-200 status and a parseable error body. It carries the HTTP status code, the server-provided status string, and the human-readable message.

func (*ServerError) Error added in v1.2.1

func (e *ServerError) Error() string

type SignedResponse

type SignedResponse struct {
	Payload   string `json:"payload"`
	Signature string `json:"signature"`
}

SignedResponse is the raw response from the license server.

type State added in v1.2.12

type State struct {
	IsProEnabled bool      `json:"is_pro_enabled"`
	Plan         string    `json:"plan,omitempty"`
	Features     []string  `json:"features,omitempty"`
	Status       string    `json:"status"`
	VerifiedAt   time.Time `json:"verified_at,omitempty"`
	ExpiresAt    time.Time `json:"expires_at,omitempty"`
	Message      string    `json:"message,omitempty"`
}

State represents the current license status, safe to read concurrently.

Jump to

Keyboard shortcuts

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