Documentation
¶
Overview ¶
Package offline is what the SDK decides from what the device holds, without asking the server (the reference's offline.ts): whether a lease licenses this build, what a trial shows, which refusal still stands, and when to ask again.
Index ¶
- Constants
- func ActivationPatch(key, activationID, leaseText string, c *lease.Claims, now float64, major int, ...) state.Patch
- func AskDue(s state.State, clockNow float64, force bool) bool
- func AsksOnValidLease(c *lease.Claims, s state.State, major int, now, clockNow float64, ...) bool
- func HeldElsewhere(v lease.Result, claims []string, canTell bool) bool
- func HeldToAnother(c *lease.Claims, claims []string, canTell bool) bool
- func KeptWith(kept *float64, c *lease.Claims, now float64, major int) *float64
- func KeyedBy(kind string) state.Patch
- func Leased() state.Patch
- func MajorOf(configured *int) int
- func RefusalPatch(refused string, major int, ownClaim *string) state.Patch
- func RenewsEarly(c *lease.Claims, now float64) bool
- func StandingRefusal(s state.State, major int, dev *DeviceView) string
- func TrialLeaseValid(v lease.Result, product string, claims []string, canTell bool) bool
- func TrialReportDue(s state.State, now float64) bool
- func Unkeyed() state.Patch
- type Check
- type DeviceView
- type Holder
- type LicensedTo
- type MeterStatus
- type RenewalInput
- type RenewalOutcome
- type Status
- type TrialLease
Constants ¶
const ( Expired = "expired" Upgrade = "upgrade" Outdated = "outdated" Tampered = "tampered" UnknownKey = "unknown-key" Device = "device" )
Why a lease does not license this build.
const ( AskAgainMs = 60 * 60_000 RetryUnansweredMs = 60_000 )
How long to wait before asking again on its own: after an answer without a lease, and after no answer at all.
const ( RefusedRevoked = "revoked" RefusedUpgrade = "upgrade" RefusedOutdated = "outdated" RefusedDevice = "device" )
The refusals the server gives, as stored.
const ( Licensed = "licensed" Trial = "trial" ExpiredS = "expired" Invalid = "invalid" Unlicensed = "unlicensed" Unknown = "unknown" )
The states a status is in.
const ( Revoked = "revoked" Offline = "offline" TrialReason = "trial" Storage = "storage" RevokedFile = "revoked-file" )
The reasons a status gives (besides the lease reasons of check.go).
const DayMs = 86_400_000
DayMs is a day in milliseconds.
const RenewWithinMs = 7 * 24 * 60 * 60_000
RenewWithinMs is how near its end a valid lease is renewed early.
const TrialReportMs = DayMs
TrialReportMs is how often, at most, a running trial reports its launch.
Variables ¶
This section is empty.
Functions ¶
func ActivationPatch ¶
func ActivationPatch(key, activationID, leaseText string, c *lease.Claims, now float64, major int, kind string) state.Patch
ActivationPatch is what an activation saves (activationPatch): the key, the activation, the lease, the major heard, the kept major, refusal and wait cleared, and what the install is keyed by (cleared for a kind not known).
func AskDue ¶
AskDue is whether to ask the server now (askDue): forced; no wait recorded; the device clock before the recorded ask; or the wait over.
func AsksOnValidLease ¶
func AsksOnValidLease(c *lease.Claims, s state.State, major int, now, clockNow float64, journalAsks bool) bool
AsksOnValidLease is whether status(), holding a lease that licenses this build, asks the server now (asksOnValidLease): a newer major than the server last heard on an open lease, the lease near its end, or a journal to report whose wait is not running; and only when the wait allows.
func HeldElsewhere ¶
HeldElsewhere is whether a licence lease, valid or merely expired, is held to a machine that is not this device (heldElsewhere).
func HeldToAnother ¶
HeldToAnother is whether a lease's claims hold it to a machine this run can tell is not this device: only a seat keyed by a machine id (fp, fpk machine), and only when this run can tell who the device is.
func KeptWith ¶
KeptWith is kept after running major on a lease with these claims at now (keptWith): raised to it while the lease carries an open upgrade window and now is before its end, else as it was.
func KeyedBy ¶
KeyedBy is what a check-in with a device of this kind writes of the install's key: a machine id read here keys it (keyedBy).
func MajorOf ¶
MajorOf is the major a build runs as (majorOf): the configured one, none read as 1, and never below 1 (a 0.x build is major 1).
func RefusalPatch ¶
RefusalPatch is what storing the server's refusal changes (refusalPatch): revoked drops the lease; upgrade and outdated keep it, with the major refused; device keeps it, with the device's own claim (none when it has none).
func RenewsEarly ¶
RenewsEarly is whether a valid lease is near enough its end at now to renew it early: less than RenewWithinMs left, or less than half its life when that is shorter.
func StandingRefusal ¶
func StandingRefusal(s state.State, major int, dev *DeviceView) string
StandingRefusal is the stored refusal that still stands for a build running major, or "" (standingRefusal): a device refusal stored with refusedFor only while this run can tell and its own claim is in it; revoked, a device refusal without refusedFor, and one with no refusedMajor always; upgrade for that major and newer; outdated for it and older.
func TrialLeaseValid ¶
TrialLeaseValid is whether a verified trial lease runs a trial here (trialLeaseValid): valid, a trial's, this product's, and either not started under a machine id, or this run cannot tell, or its aid is this device's.
func TrialReportDue ¶
TrialReportDue is whether a running trial reports its launch at now, the guarded clock (trialReportDue): neither trialAt nor trialReportedAt within a day before now (one ahead of now is within it).
Types ¶
type Check ¶
type Check struct {
OK bool
Test bool
Claims *lease.Claims // set when OK
Reason string // set when not OK
}
Check is what a lease says about this build, offline: OK with whether it is a test licence's and its claims, or the reason it does not license.
func CheckLease ¶
CheckLease is a verified licence lease held to this product, this holder and this build's major (checkLease), in order: not valid (expired, unknown-key, else tampered); another product, key (without case) or activation (tampered); held to a machine this run can tell is another (device); below minMajor (outdated); above major (upgrade); else licensed.
type DeviceView ¶
Who the device is, as the decisions that take one read it: its own claim, and whether this run can tell (nil: no device read).
type Holder ¶
type Holder struct {
Key string
ActivationID string
Claims []string // every fp claim this device answers to
CanTell bool // whether this run could tell who the device is
}
Holder is whose a licence lease must be: the key and activation stored, and this device.
type LicensedTo ¶
type LicensedTo struct {
Name, Email *string
}
LicensedTo is who a licence file is licensed to.
type MeterStatus ¶
MeterStatus is one meter as a status shows it (sdk-contract.md 12.8).
type RenewalInput ¶
type RenewalInput struct {
Response *wire.Response // nil when there was no answer at all
Check *Check // the offline check of the lease a 200 carried, else nil
AskedAt float64 // the device clock when the ask was made
Now float64 // the time the lease was judged at
Major int
Key string // the stored key ("" for none)
Kept *float64 // the stored kept major
Kind string // what the device's own fingerprint hashes
OwnClaim *string
}
RenewalInput is what an ask's answer is judged from (renewal.ts RenewalInput).
type RenewalOutcome ¶
RenewalOutcome is what an ask's answer does: whether the server answered at all, the status it gives (nil: none), and what is saved as the answer.
func Renewal ¶
func Renewal(in RenewalInput) RenewalOutcome
Renewal is what a validate's answer saves and says (renewalOutcome): no answer waits a minute; a 5xx or 429 waits an hour; a 200 with a lease that licenses this build, or one the server stands behind for another build or device, is kept; any other 200 waits an hour; a refusal is stored; anything else waits an hour. Every patch is keyed by a machine id read here.
type Status ¶
type Status struct {
State string
Reason string
Key string
TrialDaysLeft *float64
TrialEndsAt *float64
Test bool
Entitlements lease.Entitlements
Meters map[string]MeterStatus
Source string
LicensedTo *LicensedTo
Stalled bool
}
Status is what status() says (LicenseStatus). An empty text is absent; nil or empty maps are absent.
func LeaseStatus ¶
LeaseStatus is the status a stored licence lease gives, judged offline, when the server gives no verdict (leaseStatus): licensed, with test and its entitlements; expired/offline; invalid with the reason and the key; or invalid/tampered with no key.
func TrialStatusOf ¶
func TrialStatusOf(s state.State, now float64, leaseValid bool, leaseEndsAt *float64, ent lease.Entitlements) Status
TrialStatusOf is a trial's status from what the device holds (trialStatusOf): unlicensed with no trial evidence; expired/trial unless its lease is valid; else trial, ending when the lease was signed to (the stored end only when that is not known), with its days left and its entitlements.
type TrialLease ¶
type TrialLease struct {
Valid bool
EndsAt *float64 // its exp in ms, when valid
Entitlements lease.Entitlements
}
TrialLease is what a trial's status reads of its trial lease (trialLeaseOf).
func TrialLeaseOf ¶
TrialLeaseOf is a verified trial lease as a status reads it.