pickup

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func Ask(email string, code string, hasCode bool) (sendEmail, sendCode, refused string)

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

func Chosen(keys []Key, major int, now float64) (index int, refused string)

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

func Covers(v *Versions, major int, now float64) bool

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

func Refusal(json any) (word string, retryAfter *float64)

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

func KeysOf(json any) ([]Key, bool)

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.

type Sale

type Sale struct {
	ID          string
	Index, Size float64
}

Sale is the sale a picked key is one of.

type Versions

type Versions struct {
	MinMajor     float64
	MaxMajor     *float64
	UpgradeUntil *float64
}

Versions are the majors a picked key covers: from MinMajor; up to MaxMajor (nil: open), or every major while UpgradeUntil (ms; nil: none) is ahead.

Jump to

Keyboard shortcuts

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