controlplane

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFreemiusEvent

func ApplyFreemiusEvent(store *Store, ev FreemiusWebhookEvent) error

ApplyFreemiusEvent updates license state from a webhook (idempotent).

func EncodeJSON

func EncodeJSON(w interface{ Write([]byte) (int, error) }, v any) error

EncodeJSON writes v as JSON to w.

func IssueToken

func IssueToken(rec *LicenseRecord, key ed25519.PrivateKey) (string, entitlement.State, error)

IssueToken signs an entitlement JWT for a license record.

func Listen

func Listen(addr string, handler http.Handler) error

Listen starts the HTTP server with sane timeouts for the sandbox API.

Types

type Config

type Config struct {
	Addr          string
	WebhookSecret string
	SigningKey    ed25519.PrivateKey
	Version       string
}

Config configures the control plane HTTP server.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig reads server config from environment.

type FreemiusWebhookEvent

type FreemiusWebhookEvent struct {
	EventID    string `json:"event_id,omitempty"`
	Event      string `json:"event"`
	LicenseKey string `json:"license_key"`
	Plan       string `json:"plan"`
	UserID     string `json:"user_id"`
	Email      string `json:"email"`
}

FreemiusWebhookEvent is the sandbox webhook payload shape.

type LicenseRecord

type LicenseRecord struct {
	LicenseKey   string
	Plan         entitlement.Plan
	Subject      string
	Entitlements []string
	Revoked      bool
	Version      int
}

LicenseRecord is the server-side view of a Freemius license.

type PackageOffer

type PackageOffer struct {
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Entitlements []string `json:"entitlements"`
}

PackageOffer is a catalog entry returned by the API.

func PackageCatalog

func PackageCatalog() []PackageOffer

PackageCatalog returns curated package metadata for GET /v1/packages.

type Server

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

Server is the control plane HTTP API.

func NewServer

func NewServer(cfg Config) (*Server, error)

NewServer constructs a Server with an in-memory license store.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the root http.Handler.

type Store

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

Store holds license records in memory (Phase 1; Postgres in production).

func NewStore

func NewStore() *Store

func (*Store) GetLicense

func (s *Store) GetLicense(key string) (*LicenseRecord, bool)

func (*Store) MarkWebhookSeen

func (s *Store) MarkWebhookSeen(id string) bool

func (*Store) RevokeLicense

func (s *Store) RevokeLicense(key string)

func (*Store) UpsertLicense

func (s *Store) UpsertLicense(rec LicenseRecord)

Jump to

Keyboard shortcuts

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