Documentation
¶
Overview ¶
Package pickup is key pickup's logic (sdk-contract.md section 13; the reference's pickup.ts): what a person typed prepared to send, a refusal's word, a confirm's keys read leniently, and the key a restore activates.
Index ¶
- Constants
- func Ask(email string, code string, hasCode bool) (sendEmail, sendCode, refused string)
- func Chosen(keys []Key, major int, now float64) (index int, refused string)
- func Covers(v *Versions, major int, now float64) bool
- func Refusal(json any) (word string, retryAfter *float64)
- type Key
- type Sale
- type Versions
Constants ¶
const ( PickupDisabled = "pickup-disabled" WrongCode = "wrong-code" CodeExpired = "code-expired" TooManyAttempts = "too-many-attempts" TryAgain = "try-again" InvalidEmail = "invalid-email" Network = "network" NoKey = "no-key" Upgrade = "upgrade" Outdated = "outdated" )
The words a pickup refuses with (PickupError), and a restore's own.
const KeepKeys = 10 * time.Minute
KeepKeys is how long a confirm's keys are kept in memory, by the address and code sent (PICKUP_KEYS_KEEP_MS): a code's life.
Variables ¶
This section is empty.
Functions ¶
func Ask ¶
Ask is what a person typed, prepared to send (pickupAsk): the address trimmed as a key is, a blank one or one past wire.MaxEmail UTF-16 units refused invalid-email; with a code (hasCode), the code as an activation's (ends trimmed, spaces dropped), a blank one or one not six ASCII digits refused wrong-code. The address is judged first.
func Chosen ¶
Chosen is the key a restore activates (chosenKey): of the keys that cover the build, in order, the first held, else the first with a free seat, else the first; no keys no-key; none covering upgrade when one is for an older major, else outdated.
func Covers ¶
Covers is whether versions cover the build's major at now (ms, the device clock): none (unbound) covers any; else from MinMajor, up to MaxMajor (or open), or any major while the upgrade window is ahead.
func Refusal ¶
Refusal is a refused call's error and wait (pickupRefusal), from the body's word, never the status: the pickup's own words as they are; rate-limited as too-many-attempts, unavailable as try-again, invalid-request as invalid-email; anything else, or none, network. retryAfter (seconds) is kept on too-many-attempts and try-again when the body gives it as a whole number.
Types ¶
type Key ¶
type Key struct {
Key string
Model string
ModelName *string
State string
Entitlements lease.Entitlements
ExpiresAt *float64
Versions *Versions // nil: sold without a version and not yet bound
DeviceLimit float64
ActiveDevices float64
Held bool
Sale *Sale
ActivationCode string // "" when none
}
Key is one key a confirm handed back, as read (PickedKey).
func KeysOf ¶
KeysOf is a confirm's keys as read (pickedKeysOf): false when the body is not an object or its keys not a list; each member an object whose key is text of 1 to wire.MaxKey UTF-16 units kept, in order, the rest left out, a kept key's other fields falling back when they are not what they should be.