Documentation
¶
Index ¶
- func ApplyFreemiusEvent(store *Store, ev FreemiusWebhookEvent, planMap map[string]entitlement.Plan) error
- func EncodeJSON(w interface{ ... }, v any) error
- func IssueToken(rec *LicenseRecord, key ed25519.PrivateKey) (string, entitlement.State, error)
- func Listen(addr string, handler http.Handler) error
- type Config
- type FreemiusWebhookEvent
- type LicenseRecord
- type PackageOffer
- type Server
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyFreemiusEvent ¶
func ApplyFreemiusEvent(store *Store, ev FreemiusWebhookEvent, planMap map[string]entitlement.Plan) error
ApplyFreemiusEvent updates license state from a webhook (idempotent).
func EncodeJSON ¶
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.
Types ¶
type Config ¶
type Config struct {
Addr string
Env string // "dev" (default) or "production"
DBPath string
WebhookSecret string
SigningKey ed25519.PrivateKey
FreemiusPlans map[string]entitlement.Plan // Freemius plan ID -> our plan name
Version string
}
Config configures the control plane HTTP server.
func LoadConfig ¶
LoadConfig reads server config from environment.
func (Config) IsProduction ¶ added in v0.8.0
IsProduction reports whether the server is running in production mode, which disables sandbox license seeding and requires an explicit signing key.
type FreemiusWebhookEvent ¶
type FreemiusWebhookEvent struct {
EventID string
Event string
LicenseKey string
PlanID string
Plan string
UserID string
Email string
}
FreemiusWebhookEvent is the normalized shape we act on, after extracting it from either Freemius's real nested payload or the flat sandbox shape used for local testing (see controlplane/README.md).
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 ¶
NewServer constructs a Server backed by the SQLite license store at cfg.DBPath. Sandbox licenses are only seeded outside production.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists license and webhook-idempotency state to a local SQLite file. A restart or redeploy must not lose customer license records, which an in-memory store would.
func NewStore ¶
NewStore opens (creating if needed) the SQLite-backed license store at path. When seedSandbox is true, two fixed sandbox licenses are inserted so `m controlplane serve` works out of the box for local testing — this must be false in production.
func (*Store) GetLicense ¶
func (s *Store) GetLicense(key string) (*LicenseRecord, bool)
func (*Store) MarkWebhookSeen ¶
MarkWebhookSeen records a webhook event id and reports whether this is the first time it's been seen (false means it's a duplicate delivery — skip re-applying it).
func (*Store) RevokeLicense ¶
RevokeLicense marks a license revoked without deleting its history.
func (*Store) UpsertLicense ¶
func (s *Store) UpsertLicense(rec LicenseRecord) error
UpsertLicense inserts or updates a license record (idempotent per webhook delivery), bumping the version on update so cached client entitlements know to refresh.