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
- Variables
- func EncodeURIComponent(s string) string
- func EnteredCode(code string) (string, bool)
- func EnteredKey(key string) (string, bool)
- func ErrorOf(body any) any
- func MapServerError(word any) string
- func NoAnswer(status int) bool
- func ReferencedLink(link, ref string) (string, error)
- func RefusalOf(word any) string
- func SameKey(a, b string) bool
- func TrimToLength(value string, max int) string
- func TypedFor(email, code string) (sendEmail, sendCode, refused string)
- type LeaseBody
- type Response
- type TrialBody
Constants ¶
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).
const MaxDeviceName = 120
MaxDeviceName is the longest device name the activate endpoint keeps, in UTF-16 units; a longer one is cut, not refused.
const MaxEmail = 254
MaxEmail is the longest address the endpoints take, in UTF-16 units.
const MaxKey = 120
MaxKey is the longest licence key the endpoints take, in UTF-16 units.
Variables ¶
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 ¶
EncodeURIComponent is JavaScript's encodeURIComponent: every byte of the UTF-8 percent-encoded, upper-case, but A-Z a-z 0-9 - _ . ! ~ * ' ( ).
func EnteredCode ¶
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 ¶
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 ¶
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 ¶
MapServerError is an activation's error word as the app's error (mapServerError); anything else, a non-text included, is network.
func ReferencedLink ¶
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 ¶
RefusalOf is the refusal a validate's error word is, or "" for any other word (refusalOf).
func SameKey ¶
SameKey is whether two licence keys are the same key: the server matches them without regard to case (sameKey).
func TrimToLength ¶
TrimToLength is value cut to max UTF-16 units without splitting a character (trimToLength).
func TypedFor ¶
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 ¶
ParseLeaseBody keeps a body's lease and activationId when they are texts.