wire

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: 5 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 wire is what the SDK sends and reads on the wire (the reference's wire.ts): the server's error words, the bounds the endpoints hold strings to, and the shapes of their answers.

Index

Constants

View Source
const (
	InvalidKey        = "invalid-key"
	Limit             = "limit"
	Revoked           = "revoked"
	Upgrade           = "upgrade"
	Outdated          = "outdated"
	Network           = "network"
	InvalidLease      = "invalid-lease"
	UserEmailRequired = "user-email-required"
	UserEmailMismatch = "user-email-mismatch"
	UserCodeRequired  = "user-code-required"
	UserCodeInvalid   = "user-code-invalid"
	TooManyCodes      = "too-many-codes"
	TooManyAttempts   = "too-many-attempts"
	TryAgain          = "try-again"
)

The errors an activation answers (LicenseError).

View Source
const MaxDeviceName = 120

MaxDeviceName is the longest device name the activate endpoint keeps, in UTF-16 units; a longer one is cut, not refused.

View Source
const MaxEmail = 254

MaxEmail is the longest address the endpoints take, in UTF-16 units.

View Source
const MaxKey = 120

MaxKey is the longest licence key the endpoints take, in UTF-16 units.

Variables

View Source
var ErrNotAbsolute = errors.New("keygrant: the payment link is not an absolute URL")

ErrNotAbsolute is a payment link that is not an absolute URL.

Functions

func EncodeURIComponent

func EncodeURIComponent(s string) string

EncodeURIComponent is JavaScript's encodeURIComponent: every byte of the UTF-8 percent-encoded, upper-case, but A-Z a-z 0-9 - _ . ! ~ * ' ( ).

func EnteredCode

func EnteredCode(code string) (string, bool)

EnteredCode is the code a person entered: its ends trimmed, its spaces (U+0020) dropped; "" when there is none; false when it is not exactly six ASCII digits.

func EnteredKey

func EnteredKey(key string) (string, bool)

EnteredKey is the key a person entered, normalised (trimmed as JavaScript's trim does, then upper-cased as its toUpperCase does), and false when it cannot be a key: empty, or longer than MaxKey after that (enteredKey).

func ErrorOf

func ErrorOf(body any) any

ErrorOf is a body's error member (errorOf): nil for a body that is not an object or has none. A JSON array is an object to JavaScript, with no error.

func MapServerError

func MapServerError(word any) string

MapServerError is an activation's error word as the app's error (mapServerError); anything else, a non-text included, is network.

func NoAnswer

func NoAnswer(status int) bool

NoAnswer is whether a status is no answer at all: a 5xx or a 429.

func ReferencedLink(link, ref string) (string, error)

ReferencedLink is link with ref as its one client_reference_id (referencedLink): the link read as an absolute URL, then its query edited as text: every parameter named exactly client_reference_id (its text before the first "=", or all of it) and every empty one left out, the others kept as written and in order, and client_reference_id=<ref> (percent-encoded as a URI component) added last. The fragment is kept.

The text is edited as given, where JavaScript's URL would first write it in its normal form (a lower-case scheme and host, say); a payment link is written so already (sdk-contract.md 5.4 leaves this to the platform's URL).

func RefusalOf

func RefusalOf(word any) string

RefusalOf is the refusal a validate's error word is, or "" for any other word (refusalOf).

func SameKey

func SameKey(a, b string) bool

SameKey is whether two licence keys are the same key: the server matches them without regard to case (sameKey).

func TrimToLength

func TrimToLength(value string, max int) string

TrimToLength is value cut to max UTF-16 units without splitting a character (trimToLength).

func TypedFor

func TypedFor(email, code string) (sendEmail, sendCode, refused string)

TypedFor is what an activation sends for what a person typed for a user-locked key, or the error that refuses it before anything is sent (typedFor): the address trimmed, none when blank, user-email-mismatch past MaxEmail; the code's ends trimmed and its spaces dropped, none when blank, user-code-invalid unless six ASCII digits. The address is judged first.

Types

type LeaseBody

type LeaseBody struct {
	Lease, ActivationID *string
}

LeaseBody is what a lease body carries (parseLeaseBody): each only when a text.

func ParseLeaseBody

func ParseLeaseBody(body any) LeaseBody

ParseLeaseBody keeps a body's lease and activationId when they are texts.

type Response

type Response struct {
	Status int
	JSON   any
}

Response is a request's answer: its HTTP status and its body as JSON (nil when it had none or it did not parse).

type TrialBody

type TrialBody struct {
	TrialStart, TrialEndsAt float64
	Lease                   *string
}

TrialBody is a trial answer (parseTrialBody).

func ParseTrialBody

func ParseTrialBody(body any) *TrialBody

ParseTrialBody is a trial answer's body, or nil when its trialStart or trialEndsAt is not a number.

Jump to

Keyboard shortcuts

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