Documentation
¶
Overview ¶
Package latte is the Go client SDK for LicenseLatte.
Typical usage:
sdk, err := latte.New(&latte.Config{AppID: "pk_live_..."})
if err != nil { /* bad config */ }
license, err := sdk.Activate(licenseKey)
if err != nil { /* handle: ErrLicenseExpired, ErrSeatLimit, etc. */ }
// Periodically (e.g. on startup, every N minutes):
license, err = sdk.Check()
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidKey is returned when the provided license key fails format/checksum validation. ErrInvalidKey = errors.New("licenselatte: invalid license key") // ErrLicenseExpired is returned when the token is past its grace period. ErrLicenseExpired = errors.New("licenselatte: license expired") // ErrNotActivated is returned by Check when no token has been stored yet. ErrNotActivated = errors.New("licenselatte: not activated on this machine") // ErrSeatLimit is returned when all activation slots on the license are occupied. ErrSeatLimit = errors.New("licenselatte: activation seat limit reached") // ErrLicenseNotFound is returned when the provided license key is valid but not found on the server. ErrLicenseNotFound = errors.New("licenselatte: license not found") // ErrInvalidProjectKey is returned when the provided project key is invalid, this is a config error. ErrInvalidProjectKey = errors.New("licenselatte: invalid project key") )
Sentinel errors returned by Activate, Check, and Renew.
var ( // ErrInvalidAppID is returned when the provided AppID is invalid. ErrInvalidAppID = errors.New("licenselatte: invalid AppID") // ErrUnknownEnvironment is returned when the provided environment is unknown. Expected values are "live", "test", or "local". ErrUnknownEnvironment = errors.New("licenselatte: unknown environment") // ErrInvalidAppIDKeySegment is returned when the provided AppID key segment is invalid. ErrInvalidAppIDKeySegment = errors.New("licenselatte: invalid app id key segment") // ErrInvalidAppIDChecksum is returned when the provided AppID checksum is invalid. ErrInvalidAppIDChecksum = errors.New("licenselatte: invalid app id checksum") )
Sentinel errors returned by the internal app id parser. They are config errors.
var ( // ErrStorageInitFailed is returned when the SDK cannot initialize the storage. ErrStorageInitFailed = errors.New("licenselatte: cannot initialize storage") // ErrMachineIDFailed is returned when the SDK cannot determine the machine ID. ErrMachineIDFailed = errors.New("licenselatte: cannot determine machine ID") )
Sentinel errors returned by the SDK instance creation. They are runtime errors.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// AppID is the project key shown in the LicenseLatte dashboard (pk_live_… / pk_test_… / pk_local_…).
AppID string
}
type License ¶
type License struct {
// Key is the raw license key (no hyphens).
Key string
// ActivationID is the server UUID for this machine's activation slot.
ActivationID string
// ProjectID is the UUID of the owning project.
ProjectID string
// IssuedAt is the timestamp when the server issued the license.
IssuedAt time.Time
// ExpiresAt is the hard expiry of the current token (far-future for perpetual).
ExpiresAt time.Time
// GracePeriod is the offline tolerance window after ExpiresAt.
GracePeriod time.Duration
// InGracePeriod is true when the token has expired but the grace window
// has not elapsed. The application should surface a "please reconnect" warning.
InGracePeriod bool
// LicenseType is "perpetual_fixed", "perpetual", or "expiring".
LicenseType string
// Metadata contains the public metadata configured for the license in the dashboard
Metadata map[string]string
}
License is a validated, active license returned by Activate and Check.
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
SDK is the main entry point. Create one instance per application.
func New ¶
New creates a new SDK instance. Returns an error if AppID is invalid or the local token-storage directory cannot be created.
func (*SDK) Activate ¶
Activate validates the license key and activates this machine.
On the happy path it returns a *License immediately from the local token cache. If no valid cached token exists, it calls the LicenseLatte API to activate. A background goroutine silently renews the token whenever a valid cache hit occurs, so the local copy stays fresh.
func (*SDK) ActivateWithContext ¶
ActivateWithContext is the context-aware version of Activate.
func (*SDK) Check ¶
Check validates the locally-stored token without making a network call. Returns ErrNotActivated if Activate has never been called on this machine. Returns ErrLicenseExpired if the token is past its grace period.
Use this for periodic in-process checks (e.g. before allowing a gated feature).
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
sdktest
command
sdktest is a manual integration test binary.
|
sdktest is a manual integration test binary. |
|
validator
command
validator is a low-level debug tool that activates a license and prints the raw JWT claims.
|
validator is a low-level debug tool that activates a license and prints the raw JWT claims. |
|
example
|
|
|
simple
command
|
|
|
internal
|
|