carlos / platform Public

cli: carlos domains transfer

carlos domains transfer <name> --auth-code <code|-> [--contact <id> |
--contact-file f] [--yes] [--no-wait] moves a domain registered
elsewhere here, by name. It shows the price and the nameservers kept,
confirms, prints the Checkout link, then waits on the purchase status
door, printing each new state and stage once, until done, failed,
expired or unpaid (never for live: its DNS is elsewhere), polling once a
minute while the current registrar has it. --auth-code - reads one line
from stdin; the code travels only in the start's POST body and is taken
out of any error text.

Console doors (persons, owners, domainBuyAPIGate, service-closed,
gateNoHostClaim): POST .../domains/transfers/check {"name","country"}
answers the quote and nameservers (quoteTransfer, now with an optional
country, as the buy check); POST .../domains/transfers starts it
(startDomainTransfer) and answers {"id","checkout_url","state"}, with
codes auth_code, contact and price_changed for what the CLI can put
right. Strings are drafts; parity row, closed-door registers, cli.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ae6c44eaff567d5884e0e3d67e46a7552a43a638 parent a185a51
15 files changed, +1,097 −44
  • apimode.go +2 −12
  • docs/parity.md +3 −3
  • docs/site/cli.md +13 −0
  • domains_buy_copy.go +53 −0
  • domains_cli.go +3 −2
  • domains_transfer_cli.go +340 −0
  • domains_transfer_cli_test.go +324 −0
  • internal/console/apidomainbuy.go +121 −15
  • internal/console/apidomainbuy_test.go +212 −0
  • internal/console/domaintransfer_start.go +5 −3
  • internal/console/routedecls.go +5 −0
  • internal/console/svcroutes_test.go +6 −2
  • parity/cli.tsv +1 −0
  • parity/parity.tsv +1 −1
  • testdata/clireg-golden.jsonl +8 −6
diff --git a/apimode.go b/apimode.go
index 6284e01f8..5f680b7fd 100644
--- a/apimode.go
+++ b/apimode.go
@@ -4956,6 +4956,7 @@ type domainPurchaseResp struct {
Reason string `json:"reason"`
DomainState string `json:"domain_state"`
Pointed *bool `json:"pointed"` // nil from a console that predates it
+ Stage string `json:"stage"` // a transfer's card stage
}
type domainContactError struct{ error }
@@ -5003,18 +5004,7 @@ func (s *apiSession) postDomainPurchase(ctx context.Context, acct apiAcct, in do
return out, err
}
if status != http.StatusOK {
- err := apiErrorFromBody(status, body)
- var refusal struct {
- Code string `json:"code"`
- domainQuoteResp
- }
- if status == http.StatusConflict && json.Unmarshal(body, &refusal) == nil && refusal.Code == "price_changed" && refusal.Currency != "" && refusal.Price > 0 {
- return out, &domainPriceChangedError{err, refusal.domainQuoteResp}
- }
- if status == http.StatusUnprocessableEntity && json.Unmarshal(body, &refusal) == nil && refusal.Code == "contact" {
- return out, &domainContactError{err}
- }
- return out, err
+ return out, domainStartError(status, body)
}
if err := json.Unmarshal(body, &out); err != nil {
return out, fmt.Errorf(domainsBuyCopy["unreadablePurchase"], err)
diff --git a/docs/parity.md b/docs/parity.md
index 3eda11e60..39aa5777c 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -10,11 +10,11 @@ CLI rows are checked against the command registry (`parity/cli.tsv`).
| Status | Rows |
|---|---:|
-| both | 47 |
+| both | 48 |
| partial | 9 |
| gap | 67 |
| cli-only | 19 |
-| console-only | 19 |
+| console-only | 18 |
| Total | 161 |
## account
@@ -110,7 +110,7 @@ CLI rows are checked against the command registry (`parity/cli.tsv`).
| domains-verify | partial | `domains verify` | `POST /a/{sqid}/apps/{app}/domains/attach` | | There is no Verify button; attaching again verifies. |
| domains-buy | both | `domains check`<br>`domains buy` | `GET /a/{sqid}/domains/buy`<br>`POST /a/{sqid}/domains/buy/check`<br>`POST /a/{sqid}/domains/buy`<br>`GET /a/{sqid}/domains/purchases/{id}`<br>`GET /a/{sqid}/domains/purchases/{id}/status`<br>`GET /a/{sqid}/apps/{app}/domains/buy`<br>`POST /a/{sqid}/apps/{app}/domains/check`<br>`POST /a/{sqid}/apps/{app}/domains/buy`<br>`GET /a/{sqid}/apps/{app}/domains/purchases/{id}`<br>`GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status` | | The app-scoped routes only redirect to the account's. |
| domains-contacts | both | `domains contacts list`<br>`domains contacts add`<br>`domains contacts edit`<br>`domains contacts remove` | `POST /a/{sqid}/domains/contacts`<br>`POST /a/{sqid}/domains/contacts/{id}`<br>`POST /a/{sqid}/domains/contacts/{id}/remove` | | Saved contacts are added, edited and removed on the Domains page and with domains contacts; a purchase with no contact named uses the most recently used one. |
-| domains-transfer | console-only | | `GET /a/{sqid}/domains/transfer/{domain}`<br>`POST /a/{sqid}/domains/transfer/{domain}` | | Moving a domain registered elsewhere here (Move to Carloku): the form and its start; the move's card is the purchase card. No CLI command yet. |
+| domains-transfer | both | `domains transfer` | `GET /a/{sqid}/domains/transfer/{domain}`<br>`POST /a/{sqid}/domains/transfer/{domain}` | | Moving a domain registered elsewhere here (Move to Carloku): the form and its start, and domains transfer, which moves one by name; the move's card is the purchase card, and the CLI waits on its status. |
| domains-point | both | `domains point` | `POST /a/{sqid}/apps/{app}/domains/point` | | |
| domains-paths | gap | `domains paths` | | [wp-settings](#wp-settings) | |
| domains-placements | gap | `domains placements` | | [wp-settings](#wp-settings) | |
diff --git a/docs/site/cli.md b/docs/site/cli.md
index 3923a88ca..b7952f7cd 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -1758,6 +1758,7 @@ carlos domains check shop.example
carlos domains buy shop.example --app shop
carlos domains buy shop.example --not-yet
carlos domains point shop.example --app shop
+carlos domains transfer shop.example --auth-code -
carlos domains list --all
```
@@ -1774,6 +1775,18 @@ another, and `--contact-file contact.json` uses new details and saves them.
`contacts add --file`, `contacts edit <id> --file` and
`contacts remove <id>` change them.
+<!-- COPY: transfers in, carlos domains transfer: draft awaiting copy review (Task 10). -->
+`transfer` moves a domain registered elsewhere here. Unlock it at its
+current registrar and get its transfer code first. The domain keeps the
+nameservers it uses today, so its DNS and email don’t change, and
+`transfer` shows them with the price before you confirm. Pass the code
+with `--auth-code`, or `--auth-code -` to type it or pipe it in on one line
+of stdin, which keeps it out of your shell history. The code is never
+printed. After you pay, `transfer` waits until the move is done or fails,
+which can take up to five days. You can stop waiting: the move carries on,
+and `carlos domains list --all` shows it. If it doesn’t go through, you get
+your money back. It takes the same contact flags as `buy`.
+
`carlos domains list --all` shows every domain the account uses, whether
bought here, still being bought or registered elsewhere, with each address
under its domain. Any member of the account can run it. Without `--all`,
diff --git a/domains_buy_copy.go b/domains_buy_copy.go
index 43e9bfd46..a06b376d6 100644
--- a/domains_buy_copy.go
+++ b/domains_buy_copy.go
@@ -137,3 +137,56 @@ var domainsAccountCopy = map[string]string{
"fileJSON": "--file must contain one contact JSON object",
"fileSize": "--file is too large (maximum 16 KiB)",
}
+
+// Draft for the copy pass (transfers in, Task 10): carlos domains transfer.
+// No registrar or DNS host is named; nothing says the domain renews.
+const domainsTransferHelp = ` transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]
+ move a domain registered elsewhere here. it keeps the
+ nameservers it uses today, so its DNS and email don’t
+ change. --auth-code - reads the transfer code from stdin.
+ waits until the move is done or fails, which can take up
+ to five days. owners only
+`
+
+// Draft for the copy pass (transfers in, Task 10).
+const domainsTransferUsage = "usage: carlos domains transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\n"
+
+// Draft for the copy pass (transfers in, Task 10).
+var domainsTransferCopy = map[string]string{
+ "authCodeFlag": "the transfer code from the domain’s current registrar, or - to read it from stdin",
+ "yesFlag": "confirm the transfer without prompting",
+ "codePrompt": "transfer code: ",
+ "codeEmpty": "--auth-code - read no transfer code from stdin",
+ "quote": "%s: %s %s to move it here, adding one year to its expiry\n",
+ "nameservers": "it keeps the nameservers it uses today: %s\n",
+ "confirm": "move this domain here? [y/N] ",
+ "confirmContact": "move this domain here, registered to %s? [y/N] ",
+ "confirmChanged": "move this domain at the new price? [y/N] ",
+ "confirmNonTTY": "use --yes to confirm the transfer when stdin is not a terminal",
+ "cancelled": "transfer cancelled",
+ "transferID": "transfer: %s\n",
+ "state": "transfer: %s\n",
+ "stateStage": "transfer: %s (%s)\n",
+ "waitingNote": "waiting for the domain’s current registrar to let it go, which can take up to five days. approve the transfer there to finish sooner. you can stop waiting: the move carries on, and carlos domains list --all shows it",
+ "done": "%s is registered here now. its DNS and email didn’t change",
+ "failed": "transfer failed: %s. the domain stays where it was, and the hold on your card was released or your payment refunded in full",
+ "expired": "checkout was not completed. nothing was charged and nothing was sent",
+ "unpaid": "the domain has moved here, but the payment did not go through. we will contact you about paying",
+ "unreadableCheck": "domains transfer: unreadable response: %w",
+ "unreadableStart": "domains transfer: unreadable response: %w",
+ "redacted": "[transfer code]",
+}
+
+// domainsTransferFailureReason is a failed transfer's reason in plain
+// words. An empty or unknown reason gets the generic line. Draft for the
+// copy pass (transfers in, Task 10).
+var domainsTransferFailureReason = map[string]string{
+ "auth_code": "the transfer code was wrong or out of date",
+ "rejected": "the current registrar turned the transfer down",
+ "timeout": "the current registrar didn’t answer in time",
+ "locked": "the domain was still locked at its current registrar",
+ "recent": "the domain was registered or moved in the last 60 days",
+ "expired": "the domain had expired too long ago to move",
+ "not_registered": "the domain isn’t registered",
+ "": "the transfer didn’t go through",
+}
diff --git a/domains_cli.go b/domains_cli.go
index 7c672a8a1..03679abd0 100644
--- a/domains_cli.go
+++ b/domains_cli.go
@@ -21,9 +21,9 @@ import (
"github.com/carlosframework/platform/internal/clireg"
)
-const domainsUsage = `usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]
+const domainsUsage = `usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]
-` + domainsBuyHelp + ` attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>
+` + domainsBuyHelp + domainsTransferHelp + ` attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>
claim a customer's hostname for the app, pointed at
--route (default: the app's single instance record, if it
has exactly one — otherwise --route is required).
@@ -101,6 +101,7 @@ func domainsCommand() *clireg.Node {
Children: []*clireg.Node{
raw("check", cust, runDomainsCheck),
raw("buy", cust, runDomainsBuy),
+ {Name: "transfer", Audience: cust, Run: clireg.RawArgsErr(runDomainsTransfer)},
raw("attach", cust, runDomainsAttach),
raw("verify", cust, runDomainsVerify),
raw("detach", cust, runDomainsDetach),
diff --git a/domains_transfer_cli.go b/domains_transfer_cli.go
new file mode 100644
index 000000000..8cdf253d9
--- /dev/null
+++ b/domains_transfer_cli.go
@@ -0,0 +1,340 @@
+package main
+
+// carlos domains transfer (transfers in, Task 10): move a domain registered
+// elsewhere here, by name. The console's transfer doors
+// (internal/console/apidomainbuy.go) check and start it; its status is the
+// purchase status door's, which `buy` waits on too.
+//
+// The transfer code is a secret: it is read from the flag or one line of
+// stdin, sent only in the start's POST body, and never printed, in output
+// or in an error (redactTransferCode).
+
+import (
+ "bufio"
+ "context"
+ "encoding/json"
+ "errors"
+ "flag"
+ "fmt"
+ "io"
+ "net/http"
+ "os"
+ "strings"
+ "time"
+
+ "github.com/carlosframework/platform/internal/plans"
+ "github.com/carlosframework/platform/internal/registrar"
+ "github.com/mattn/go-isatty"
+)
+
+// domainTransferWaitPoll is how often the wait asks while the current
+// registrar has the domain: an answer there takes hours or days, not
+// seconds.
+const domainTransferWaitPoll = time.Minute
+
+// domainTransferQuoteResp is the transfer check's answer.
+type domainTransferQuoteResp struct {
+ Domain string `json:"domain"`
+ Price int64 `json:"price"`
+ Currency string `json:"currency"`
+ Nameservers []string `json:"nameservers"`
+}
+
+// domainTransferReq is a start's body: at most one of Contact and
+// ContactID (neither registers to the contact used last).
+type domainTransferReq struct {
+ Name string `json:"name"`
+ AuthCode string `json:"auth_code"`
+ Contact *registrar.Contact `json:"contact,omitempty"`
+ ContactID string `json:"contact_id,omitempty"`
+ Currency string `json:"currency"`
+ Price int64 `json:"price"`
+}
+
+type domainTransferOptions struct {
+ authCode string // the code, or "-" to read one line from in
+ contactFile string // a new contact, from a file
+ contactID string // a saved contact; "" with no file is the last used
+ yes, noWait, terminal bool
+ in io.Reader
+ out io.Writer
+ now func() time.Time
+ wait func(context.Context, time.Duration) error
+}
+
+func runDomainsTransfer(args []string) error {
+ fs := flag.NewFlagSet("domains transfer", flag.ContinueOnError)
+ acctRaw := fs.String("account", "", domainsBuyCopy["accountFlag"])
+ acctID := fs.String("account-id", "", domainsBuyCopy["accountIDFlag"])
+ console := consoleOption(fs, domainsBuyCopy["consoleFlag"])
+ authCode := fs.String("auth-code", "", domainsTransferCopy["authCodeFlag"])
+ contactID := fs.String("contact", "", domainsAccountCopy["contactFlag"])
+ contactFile := fs.String("contact-file", "", domainsBuyCopy["contactFileFlag"])
+ yes := fs.Bool("yes", false, domainsTransferCopy["yesFlag"])
+ noWait := fs.Bool("no-wait", false, domainsBuyCopy["noWaitFlag"])
+ fs.Usage = flagUsage(fs, domainsTransferUsage)
+ pos, err := parseInterspersed(fs, args)
+ if err != nil {
+ return err
+ }
+ id := strings.TrimSpace(*contactID)
+ if len(pos) != 1 || strings.TrimSpace(pos[0]) == "" || *authCode == "" || (id != "" && *contactFile != "") {
+ return errors.New(domainsTransferUsage)
+ }
+ sess := requireAPISession("transfer", *console)
+ printUsing(stdout, sess)
+ acct := resolvedAccount(sess, acctRaw, acctID)
+ return domainsTransfer(context.Background(), sess, acct, strings.TrimSpace(pos[0]), domainTransferOptions{
+ authCode: *authCode, contactFile: *contactFile, contactID: id, yes: *yes, noWait: *noWait,
+ in: os.Stdin, out: stdout, terminal: isatty.IsTerminal(os.Stdin.Fd()),
+ now: time.Now, wait: waitDomainBuy,
+ })
+}
+
+// domainsTransfer checks name, shows the price and the nameservers it keeps,
+// confirms, starts the transfer, prints the Checkout link and waits. Every
+// error it returns has the transfer code taken out.
+func domainsTransfer(ctx context.Context, s *apiSession, acct apiAcct, name string, o domainTransferOptions) error {
+ input := bufio.NewScanner(o.in)
+ code := strings.TrimSpace(o.authCode)
+ if o.authCode == "-" {
+ if o.terminal {
+ fmt.Fprint(o.out, domainsTransferCopy["codePrompt"])
+ }
+ if !input.Scan() {
+ return errors.New(domainsTransferCopy["codeEmpty"])
+ }
+ code = strings.TrimSpace(input.Text())
+ if code == "" {
+ return errors.New(domainsTransferCopy["codeEmpty"])
+ }
+ }
+ return redactTransferCode(startDomainTransfer(ctx, s, acct, name, code, input, o), code)
+}
+
+func startDomainTransfer(ctx context.Context, s *apiSession, acct apiAcct, name, code string, input *bufio.Scanner, o domainTransferOptions) error {
+ var contact *registrar.Contact
+ var saved *apiSavedContact
+ var err error
+ if o.contactFile != "" {
+ if contact, err = readContactFile(o.contactFile, buyContactFileErrors); err != nil {
+ return err
+ }
+ } else if saved, err = pickSavedContact(ctx, s, acct, o.contactID); err != nil {
+ return err
+ }
+ country := ""
+ switch {
+ case contact != nil:
+ country = contact.Country
+ case saved != nil:
+ country = saved.Contact.Country
+ }
+ tq, err := s.postDomainTransferCheck(ctx, acct, name, country)
+ if err != nil {
+ return err
+ }
+ q := domainQuoteResp{Domain: tq.Domain, Currency: tq.Currency, Price: tq.Price, Available: true}
+ printDomainTransferQuote(o.out, q)
+ fmt.Fprintf(o.out, domainsTransferCopy["nameservers"], strings.Join(tq.Nameservers, ", "))
+ if o.yes && saved != nil {
+ fmt.Fprintf(o.out, domainsAccountCopy["contactUsed"], savedContactLabel(saved.Contact))
+ }
+ if !o.yes {
+ if !o.terminal {
+ return errors.New(domainsTransferCopy["confirmNonTTY"])
+ }
+ prompt := domainsTransferCopy["confirm"]
+ if saved != nil {
+ prompt = fmt.Sprintf(domainsTransferCopy["confirmContact"], savedContactLabel(saved.Contact))
+ }
+ if ok, err := domainTransferYes(input, o.out, prompt); !ok || err != nil {
+ return err
+ }
+ }
+ var p domainPurchaseResp
+ contactRetried, priceRetried := false, false
+ for {
+ req := domainTransferReq{Name: name, AuthCode: code, Contact: contact}
+ if contact == nil && saved != nil {
+ req.ContactID = saved.ID
+ }
+ p, err = s.postDomainTransfer(ctx, acct, req, q)
+ var contactErr *domainContactError
+ var priceErr *domainPriceChangedError
+ switch {
+ case errors.As(err, &contactErr) && !contactRetried:
+ if !o.terminal {
+ return fmt.Errorf(domainsBuyCopy["contactNonTTY"], err)
+ }
+ contactRetried = true
+ fmt.Fprintln(o.out, redactTransferCode(err, code))
+ if contact, err = promptDomainContact(input, o.out); err != nil {
+ return err
+ }
+ continue
+ case errors.As(err, &priceErr):
+ printDomainTransferQuote(o.out, priceErr.Quote)
+ if priceRetried || (o.yes && (q.Currency != priceErr.Quote.Currency || q.Price != priceErr.Quote.Price)) || (!o.yes && !o.terminal) {
+ return err
+ }
+ priceRetried = true
+ if !o.yes {
+ if ok, err := domainTransferYes(input, o.out, domainsTransferCopy["confirmChanged"]); !ok || err != nil {
+ return err
+ }
+ }
+ q = priceErr.Quote
+ continue
+ case err != nil:
+ return err
+ }
+ break
+ }
+ fmt.Fprintf(o.out, domainsTransferCopy["transferID"], p.ID)
+ if p.CheckoutURL != "" {
+ fmt.Fprintf(o.out, domainsBuyCopy["checkout"], p.CheckoutURL)
+ }
+ if p.Domain == "" {
+ p.Domain = q.Domain
+ }
+ return waitDomainTransfer(ctx, s, acct, p, o)
+}
+
+// domainTransferYes asks prompt; anything but y or yes cancels, saying so.
+func domainTransferYes(input *bufio.Scanner, out io.Writer, prompt string) (bool, error) {
+ answer, err := domainBuyAnswer(input, out, prompt)
+ if err != nil {
+ return false, err
+ }
+ if !strings.EqualFold(answer, "y") && !strings.EqualFold(answer, "yes") {
+ fmt.Fprintln(out, domainsTransferCopy["cancelled"])
+ return false, nil
+ }
+ return true, nil
+}
+
+func printDomainTransferQuote(out io.Writer, q domainQuoteResp) {
+ fmt.Fprintf(out, domainsTransferCopy["quote"], q.Domain, plans.FormatMinor(q.Currency, q.Price), strings.ToUpper(q.Currency))
+}
+
+// waitDomainTransfer polls the purchase status door, printing each new
+// state and stage once, until the transfer is done or ends without moving.
+// It never waits for the domain to serve: its DNS is hosted elsewhere.
+func waitDomainTransfer(ctx context.Context, s *apiSession, acct apiAcct, p domainPurchaseResp, o domainTransferOptions) error {
+ id, domain := p.ID, p.Domain
+ seen := map[string]bool{}
+ noted := false
+ for {
+ if err := ctx.Err(); err != nil {
+ return err
+ }
+ if key := p.State + "/" + p.Stage; p.State != "" && !seen[key] {
+ seen[key] = true
+ if p.Stage == "" {
+ fmt.Fprintf(o.out, domainsTransferCopy["state"], p.State)
+ } else {
+ fmt.Fprintf(o.out, domainsTransferCopy["stateStage"], p.State, p.Stage)
+ }
+ }
+ switch p.State {
+ case "done":
+ if p.Domain != "" {
+ domain = p.Domain
+ }
+ fmt.Fprintln(o.out, fmt.Sprintf(domainsTransferCopy["done"], domain))
+ return nil
+ case "failed":
+ reason, ok := domainsTransferFailureReason[p.Reason]
+ if !ok {
+ reason = domainsTransferFailureReason[""]
+ }
+ return fmt.Errorf(domainsTransferCopy["failed"], reason)
+ case "expired", "unpaid":
+ return errors.New(domainsTransferCopy[p.State])
+ }
+ if o.noWait {
+ return nil
+ }
+ if id == "" {
+ return errors.New(domainsBuyCopy["missingID"])
+ }
+ delay := domainBuyPollInterval
+ if p.Stage == "waiting" {
+ delay = domainTransferWaitPoll
+ if !noted {
+ fmt.Fprintln(o.out, domainsTransferCopy["waitingNote"])
+ noted = true
+ }
+ }
+ if err := o.wait(ctx, delay); err != nil {
+ return err
+ }
+ var err error
+ if p, err = s.getDomainPurchase(ctx, acct, id); err != nil {
+ return err
+ }
+ }
+}
+
+// redactTransferCode takes the transfer code out of err's text, in case
+// anything on the way (a console's refusal, a decode error) repeated it.
+func redactTransferCode(err error, code string) error {
+ if err == nil || code == "" || !strings.Contains(err.Error(), code) {
+ return err
+ }
+ return errors.New(strings.ReplaceAll(err.Error(), code, domainsTransferCopy["redacted"]))
+}
+
+func (s *apiSession) postDomainTransferCheck(ctx context.Context, acct apiAcct, name, country string) (domainTransferQuoteResp, error) {
+ var out domainTransferQuoteResp
+ status, body, err := s.postJSON(ctx, domainBuyAPIPath(acct, "/transfers/check"), struct {
+ Name string `json:"name"`
+ Country string `json:"country,omitempty"`
+ }{name, country})
+ if err != nil {
+ return out, err
+ }
+ if status != http.StatusOK {
+ return out, apiErrorFromBody(status, body)
+ }
+ if err := json.Unmarshal(body, &out); err != nil {
+ return out, fmt.Errorf(domainsTransferCopy["unreadableCheck"], err)
+ }
+ return out, nil
+}
+
+// postDomainTransfer starts the transfer at the confirmed price. The code
+// travels only in this body.
+func (s *apiSession) postDomainTransfer(ctx context.Context, acct apiAcct, in domainTransferReq, confirmed domainQuoteResp) (domainPurchaseResp, error) {
+ var out domainPurchaseResp
+ in.Currency, in.Price = confirmed.Currency, confirmed.Price
+ status, body, err := s.postJSON(ctx, domainBuyAPIPath(acct, "/transfers"), in)
+ if err != nil {
+ return out, err
+ }
+ if status != http.StatusOK {
+ return out, domainStartError(status, body)
+ }
+ if err := json.Unmarshal(body, &out); err != nil {
+ return out, fmt.Errorf(domainsTransferCopy["unreadableStart"], err)
+ }
+ return out, nil
+}
+
+// domainStartError is a refused purchase or transfer start: a changed
+// price to confirm, a contact to put right, or the console's words.
+func domainStartError(status int, body []byte) error {
+ err := apiErrorFromBody(status, body)
+ var refusal struct {
+ Code string `json:"code"`
+ domainQuoteResp
+ }
+ if status == http.StatusConflict && json.Unmarshal(body, &refusal) == nil && refusal.Code == "price_changed" && refusal.Currency != "" && refusal.Price > 0 {
+ return &domainPriceChangedError{err, refusal.domainQuoteResp}
+ }
+ if status == http.StatusUnprocessableEntity && json.Unmarshal(body, &refusal) == nil && refusal.Code == "contact" {
+ return &domainContactError{err}
+ }
+ return err
+}
diff --git a/domains_transfer_cli_test.go b/domains_transfer_cli_test.go
new file mode 100644
index 000000000..a1b229595
--- /dev/null
+++ b/domains_transfer_cli_test.go
@@ -0,0 +1,324 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+)
+
+const transferTestCode = "Xy7-secret-CODE-9"
+
+// transferTestServer is a console with the transfer check, the given start
+// and the purchase status door for t1. A nil start answers t1's Checkout.
+// Every start body is recorded.
+type transferTestServer struct {
+ *httptest.Server
+ mu sync.Mutex
+ starts []map[string]any
+ checks []map[string]any
+}
+
+func newTransferTestServer(t *testing.T, start, status http.HandlerFunc) *transferTestServer {
+ t.Helper()
+ ts := &transferTestServer{}
+ mux := http.NewServeMux()
+ mux.HandleFunc("POST "+buyTestPath+"/transfers/check", func(w http.ResponseWriter, r *http.Request) {
+ var in map[string]any
+ if err := json.NewDecoder(r.Body).Decode(&in); err != nil || in["name"] != "shop.com" {
+ t.Errorf("check body: %+v, %v", in, err)
+ }
+ if _, ok := in["auth_code"]; ok {
+ t.Error("the check was sent the transfer code")
+ }
+ ts.mu.Lock()
+ ts.checks = append(ts.checks, in)
+ ts.mu.Unlock()
+ fmt.Fprint(w, `{"domain":"shop.com","price":1200,"currency":"usd","nameservers":["ns1.example-dns.test","ns2.example-dns.test"]}`)
+ })
+ mux.HandleFunc("POST "+buyTestPath+"/transfers", func(w http.ResponseWriter, r *http.Request) {
+ if r.URL.RawQuery != "" && strings.Contains(r.URL.RawQuery, transferTestCode) {
+ t.Error("the transfer code is in the URL")
+ }
+ var in map[string]any
+ if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
+ t.Errorf("start body: %v", err)
+ }
+ ts.mu.Lock()
+ ts.starts = append(ts.starts, in)
+ ts.mu.Unlock()
+ if start != nil {
+ start(w, r)
+ return
+ }
+ fmt.Fprint(w, `{"id":"t1","checkout_url":"https://checkout.example/t1","state":"awaiting_payment"}`)
+ })
+ if status != nil {
+ mux.HandleFunc("GET "+buyTestPath+"/purchases/t1", status)
+ }
+ ts.Server = httptest.NewServer(mux)
+ t.Cleanup(ts.Close)
+ return ts
+}
+
+func (ts *transferTestServer) startBodies() []map[string]any {
+ ts.mu.Lock()
+ defer ts.mu.Unlock()
+ return append([]map[string]any(nil), ts.starts...)
+}
+
+// transferTestContact is a contact file the tests register to.
+func transferTestContact(t *testing.T) string {
+ t.Helper()
+ path := filepath.Join(t.TempDir(), "contact.json")
+ writeTransferTestFile(t, path, `{"first_name":"Jane","last_name":"Buyer","email":"buyer@example.test","phone_country_code":"353","phone":"871234567","street":"Main Street","city":"Dublin","postal_code":"D01 A123","country":"IE"}`)
+ return path
+}
+
+func writeTransferTestFile(t *testing.T, path, data string) {
+ t.Helper()
+ if err := os.WriteFile(path, []byte(data), 0o600); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func transferTestOptions(t *testing.T, out *bytes.Buffer) domainTransferOptions {
+ now := time.Unix(1700000000, 0)
+ return domainTransferOptions{authCode: transferTestCode, yes: true, contactFile: transferTestContact(t),
+ in: strings.NewReader(""), out: out,
+ now: func() time.Time { return now },
+ wait: func(ctx context.Context, d time.Duration) error { now = now.Add(d); return ctx.Err() },
+ }
+}
+
+// runTransferTestCommand runs the binary's domains transfer against base,
+// with stdin.
+func runTransferTestCommand(t *testing.T, base, stdin string, args ...string) (string, error) {
+ t.Helper()
+ bin := buildCarlos(t)
+ scratch := t.TempDir()
+ creds := filepath.Join(scratch, "credentials")
+ writeTestCredential(t, creds, base)
+ argv := append([]string{"domains", "transfer", "shop.com", "--account", "bab", "--console", base}, args...)
+ cmd := exec.Command(bin, argv...)
+ cmd.Dir = scratch
+ cmd.Stdin = strings.NewReader(stdin)
+ cmd.Env = carlosTestEnv(t, "CARLOS_CREDENTIALS="+creds, "CARLOS_DEPLOYMENT_BUCKET=", "CARLOS_DEPLOYMENT_DIR=", "CARLOS_CONFIG=")
+ out, err := cmd.CombinedOutput()
+ return string(out), err
+}
+
+// TestDomainsTransferPrintsNameserversAndCheckout: the price and the
+// nameservers the domain keeps come before anything is started; the start
+// sends the code, the contact and the confirmed price in its body; the
+// Checkout link is printed.
+func TestDomainsTransferPrintsNameserversAndCheckout(t *testing.T) {
+ ts := newTransferTestServer(t, nil, nil)
+ var out bytes.Buffer
+ o := transferTestOptions(t, &out)
+ o.noWait = true
+ if err := domainsTransfer(context.Background(), newTestSession(ts.URL), apiAcct{Seg: "bab"}, "shop.com", o); err != nil {
+ t.Fatal(err)
+ }
+ got := out.String()
+ for _, want := range []string{"shop.com", "12", "USD", "ns1.example-dns.test", "ns2.example-dns.test", "transfer: t1", "https://checkout.example/t1"} {
+ if !strings.Contains(got, want) {
+ t.Fatalf("output lacks %q:\n%s", want, got)
+ }
+ }
+ if strings.Index(got, "ns1.example-dns.test") > strings.Index(got, "https://checkout.example/t1") {
+ t.Fatalf("the nameservers come after the Checkout link:\n%s", got)
+ }
+ starts := ts.startBodies()
+ if len(starts) != 1 {
+ t.Fatalf("%d starts", len(starts))
+ }
+ in := starts[0]
+ contact, _ := in["contact"].(map[string]any)
+ if in["name"] != "shop.com" || in["auth_code"] != transferTestCode || in["currency"] != "usd" || in["price"] != float64(1200) || contact["country"] != "IE" {
+ t.Fatalf("start body %+v", in)
+ }
+ if ts.checks[0]["country"] != "IE" {
+ t.Fatalf("the check priced for %v, not the contact's country", ts.checks[0]["country"])
+ }
+
+ // Without --yes on a terminal it asks first; no is no start.
+ ts2 := newTransferTestServer(t, nil, nil)
+ out.Reset()
+ o = transferTestOptions(t, &out)
+ o.yes, o.terminal, o.in = false, true, strings.NewReader("n\n")
+ if err := domainsTransfer(context.Background(), newTestSession(ts2.URL), apiAcct{Seg: "bab"}, "shop.com", o); err != nil {
+ t.Fatal(err)
+ }
+ if len(ts2.startBodies()) != 0 || !strings.Contains(out.String(), "ns1.example-dns.test") {
+ t.Fatalf("declined: %d starts\n%s", len(ts2.startBodies()), &out)
+ }
+ // Not a terminal and no --yes: refused before any start.
+ o = transferTestOptions(t, &out)
+ o.yes = false
+ if err := domainsTransfer(context.Background(), newTestSession(ts2.URL), apiAcct{Seg: "bab"}, "shop.com", o); err == nil || len(ts2.startBodies()) != 0 {
+ t.Fatalf("non-terminal without --yes: %v, %d starts", err, len(ts2.startBodies()))
+ }
+}
+
+// TestDomainsTransferReadsAuthCodeFromStdin: --auth-code - reads one line
+// from stdin, and only that line is the code. An empty line starts
+// nothing.
+func TestDomainsTransferReadsAuthCodeFromStdin(t *testing.T) {
+ ts := newTransferTestServer(t, nil, nil)
+ contact := transferTestContact(t)
+ out, err := runTransferTestCommand(t, ts.URL, transferTestCode+"\nsecond line\n", "--auth-code", "-", "--contact-file", contact, "--yes", "--no-wait")
+ if err != nil {
+ t.Fatalf("%v\n%s", err, out)
+ }
+ starts := ts.startBodies()
+ if len(starts) != 1 || starts[0]["auth_code"] != transferTestCode {
+ t.Fatalf("starts %+v\n%s", starts, out)
+ }
+ if strings.Contains(out, transferTestCode) || !strings.Contains(out, "https://checkout.example/t1") {
+ t.Fatalf("output:\n%s", out)
+ }
+ for _, stdin := range []string{"", "\n", " \n"} {
+ out, err := runTransferTestCommand(t, ts.URL, stdin, "--auth-code", "-", "--contact-file", contact, "--yes", "--no-wait")
+ if err == nil || len(ts.startBodies()) != 1 {
+ t.Fatalf("stdin %q: %v, %d starts\n%s", stdin, err, len(ts.startBodies()), out)
+ }
+ }
+ // No --auth-code at all is the usage.
+ out, err = runTransferTestCommand(t, ts.URL, "", "--contact-file", contact, "--yes")
+ if err == nil || !strings.Contains(out, "usage: carlos domains transfer") || len(ts.startBodies()) != 1 {
+ t.Fatalf("no code: %v\n%s", err, out)
+ }
+}
+
+// TestDomainsTransferWaitsToDoneOrFailed: after Checkout it polls the
+// purchase status door, printing each new state and stage once, and ends
+// at done (never waiting for the domain to go live: its DNS is elsewhere)
+// or with an error at failed, expired or unpaid. While the current
+// registrar has it, it polls less often.
+func TestDomainsTransferWaitsToDoneOrFailed(t *testing.T) {
+ type poll struct{ state, stage string }
+ done := []poll{
+ {"awaiting_payment", "awaiting"}, {"authorised", "sending"}, {"transfer_submitting", "waiting"},
+ {"transfer_pending", "waiting"}, {"transfer_pending", "waiting"}, {"transfer_pending", "arrived"},
+ {"captured", "arrived"}, {"done", "done"},
+ }
+ n := 0
+ ts := newTransferTestServer(t, nil, func(w http.ResponseWriter, r *http.Request) {
+ if n >= len(done) {
+ t.Error("polled past done")
+ http.Error(w, "too many polls", 500)
+ return
+ }
+ json.NewEncoder(w).Encode(map[string]any{"id": "t1", "kind": "transfer", "domain": "shop.com", "state": done[n].state, "stage": done[n].stage, "pointed": false})
+ n++
+ })
+ var out bytes.Buffer
+ o := transferTestOptions(t, &out)
+ var delays []time.Duration
+ wait := o.wait
+ o.wait = func(ctx context.Context, d time.Duration) error { delays = append(delays, d); return wait(ctx, d) }
+ if err := domainsTransfer(context.Background(), newTestSession(ts.URL), apiAcct{Seg: "bab"}, "shop.com", o); err != nil {
+ t.Fatalf("%v\n%s", err, &out)
+ }
+ got := out.String()
+ for _, want := range []string{"awaiting_payment (awaiting)", "authorised (sending)", "transfer_submitting (waiting)", "transfer_pending (waiting)", "transfer_pending (arrived)", "captured (arrived)", "done (done)"} {
+ if strings.Count(got, "transfer: "+want+"\n") != 1 {
+ t.Fatalf("want %q once:\n%s", want, got)
+ }
+ }
+ if !strings.Contains(got, fmt.Sprintf(domainsTransferCopy["done"], "shop.com")) || strings.Contains(got, "domain: ") {
+ t.Fatalf("done:\n%s", got)
+ }
+ if n != len(done) {
+ t.Fatalf("%d polls, want %d", n, len(done))
+ }
+ if delays[0] != domainBuyPollInterval || delays[3] != domainTransferWaitPoll {
+ t.Fatalf("delays %v: want %s while paying and %s while the current registrar has it", delays, domainBuyPollInterval, domainTransferWaitPoll)
+ }
+ if strings.Count(got, domainsTransferCopy["waitingNote"]) != 1 {
+ t.Fatalf("the waiting note once:\n%s", got)
+ }
+
+ for _, tc := range []struct{ state, reason, want string }{
+ {"failed", "auth_code", fmt.Sprintf(domainsTransferCopy["failed"], domainsTransferFailureReason["auth_code"])},
+ {"failed", "", fmt.Sprintf(domainsTransferCopy["failed"], domainsTransferFailureReason[""])},
+ {"failed", "something_new", fmt.Sprintf(domainsTransferCopy["failed"], domainsTransferFailureReason[""])},
+ {"expired", "", domainsTransferCopy["expired"]},
+ {"unpaid", "", domainsTransferCopy["unpaid"]},
+ } {
+ t.Run(tc.state+"/"+tc.reason, func(t *testing.T) {
+ polls := 0
+ ts := newTransferTestServer(t, nil, func(w http.ResponseWriter, r *http.Request) {
+ polls++
+ state, stage := "transfer_pending", "waiting"
+ if polls > 1 {
+ state, stage = tc.state, tc.state
+ }
+ json.NewEncoder(w).Encode(map[string]any{"id": "t1", "kind": "transfer", "state": state, "stage": stage, "reason": tc.reason})
+ })
+ var out bytes.Buffer
+ err := domainsTransfer(context.Background(), newTestSession(ts.URL), apiAcct{Seg: "bab"}, "shop.com", transferTestOptions(t, &out))
+ if err == nil || err.Error() != tc.want || polls != 2 || strings.Contains(err.Error(), "%!") {
+ t.Fatalf("err %v after %d polls, want %q\n%s", err, polls, tc.want, &out)
+ }
+ })
+ }
+}
+
+// TestDomainsTransferNeverPrintsAuthCode: whatever the console answers, a
+// refusal, a changed price, an error that (wrongly) repeats the code, the
+// code is in no output and no error.
+func TestDomainsTransferNeverPrintsAuthCode(t *testing.T) {
+ refusal := func(status int, body string) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(status)
+ fmt.Fprint(w, body)
+ }
+ }
+ for _, tc := range []struct {
+ name string
+ start http.HandlerFunc
+ }{
+ {"code refused", refusal(422, `{"error":"Enter the transfer code from the domain’s current registrar.","code":"auth_code"}`)},
+ {"contact refused", refusal(422, `{"error":"check the contact details","code":"contact"}`)},
+ {"price changed", refusal(409, `{"error":"the price changed","code":"price_changed","domain":"shop.com","currency":"usd","price":1500}`)},
+ {"echoed", refusal(503, `{"error":"bad code `+transferTestCode+`"}`)},
+ {"unreadable", refusal(200, `not json `+transferTestCode)},
+ {"server error", refusal(500, ``)},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ ts := newTransferTestServer(t, tc.start, nil)
+ var out bytes.Buffer
+ err := domainsTransfer(context.Background(), newTestSession(ts.URL), apiAcct{Seg: "bab"}, "shop.com", transferTestOptions(t, &out))
+ if err == nil {
+ t.Fatalf("no error\n%s", &out)
+ }
+ if strings.Contains(out.String(), transferTestCode) || strings.Contains(err.Error(), transferTestCode) {
+ t.Fatalf("the code is shown: %v\n%s", err, &out)
+ }
+ var priceErr *domainPriceChangedError
+ if tc.name == "price changed" && !errors.As(err, &priceErr) {
+ t.Fatalf("price changed: %v", err)
+ }
+ })
+ }
+ // Through the binary: a refused start, the code given on the command
+ // line.
+ ts := newTransferTestServer(t, refusal(503, `{"error":"unavailable `+transferTestCode+`"}`), nil)
+ out, err := runTransferTestCommand(t, ts.URL, "", "--auth-code", transferTestCode, "--contact-file", transferTestContact(t), "--yes")
+ if err == nil || strings.Contains(out, transferTestCode) {
+ t.Fatalf("binary: %v\n%s", err, out)
+ }
+}
diff --git a/internal/console/apidomainbuy.go b/internal/console/apidomainbuy.go
index a00e9675d..9689b5967 100644
--- a/internal/console/apidomainbuy.go
+++ b/internal/console/apidomainbuy.go
@@ -37,13 +37,23 @@ func (s *Server) domainBuyAPIGate(w http.ResponseWriter, r *http.Request) (strin
}
func (s *Server) checkDomainBuy(ctx context.Context, acct *Account, name, country string) (domainreg.Quote, *doorRefusal) {
+ country, ref := s.quoteCountry(acct, country)
+ if ref != nil {
+ return domainreg.Quote{}, ref
+ }
+ return s.admitDomainBuy(ctx, acct, name, country)
+}
+
+// quoteCountry is the country a check prices for: the request's (two
+// capital letters, else the contact refusal), or defaultQuoteCountry's.
+func (s *Server) quoteCountry(acct *Account, country string) (string, *doorRefusal) {
if country != "" && (len(country) != 2 || country[0] < 'A' || country[0] > 'Z' || country[1] < 'A' || country[1] > 'Z') {
- return domainreg.Quote{}, &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]}
+ return "", &doorRefusal{Status: http.StatusUnprocessableEntity, Msg: domainBuyCopy["contactError"]}
}
if country == "" {
country = s.defaultQuoteCountry(acct)
}
- return s.admitDomainBuy(ctx, acct, name, country)
+ return country, nil
}
// defaultQuoteCountry is the country a quote assumes when the request names
@@ -124,19 +134,10 @@ func (s *Server) handleAPIDomainPurchase(w http.ResponseWriter, r *http.Request)
}
ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
defer cancel()
- // A request names a saved contact (contact_id), a new one, or neither:
- // then it buys with the most recently used saved contact, and with none
- // saved the contact refusal asks for one. Both is the contact refusal.
- sel := purchaseContactSelection{ID: in.ContactID, New: in.Contact}
- if in.Contact == nil && in.ContactID == "" {
- contacts, err := s.store.SavedContacts(ctx, acct.ID)
- if err != nil {
- writeDoorRefusalJSON(w, r, domainBuyUnavailable())
- return
- }
- if len(contacts) > 0 {
- sel.ID = contacts[0].ID
- }
+ sel, ref := s.apiContactSelection(ctx, acct, in.ContactID, in.Contact, PurchaseKindBuy)
+ if ref != nil {
+ writeDoorRefusalJSON(w, r, ref)
+ return
}
p, checkout, changed, ref := s.startDomainPurchase(ctx, acct, in.App, in.Name, sel, addr, domainreg.Quote{Currency: in.Currency, Price: in.Price})
if changed != nil {
@@ -154,6 +155,111 @@ func (s *Server) handleAPIDomainPurchase(w http.ResponseWriter, r *http.Request)
writeJSON(w, 200, map[string]any{"id": p.ID, "checkout_url": checkout, "state": p.State})
}
+// apiContactSelection is who an API start registers the domain to. A
+// request names a saved contact (contact_id), a new one, or neither: then
+// the most recently used saved contact, and with none saved the contact
+// refusal asks for one. Both is the contact refusal.
+func (s *Server) apiContactSelection(ctx context.Context, acct *Account, id string, contact *registrar.Contact, kind PurchaseKind) (purchaseContactSelection, *doorRefusal) {
+ sel := purchaseContactSelection{ID: id, New: contact}
+ if contact != nil || id != "" {
+ return sel, nil
+ }
+ contacts, err := s.store.SavedContacts(ctx, acct.ID)
+ if err != nil {
+ return sel, purchaseUnavailable(kind)
+ }
+ if len(contacts) > 0 {
+ sel.ID = contacts[0].ID
+ }
+ return sel, nil
+}
+
+// handleAPIDomainTransferCheck is POST .../domains/transfers/check
+// {"name","country"}: what moving the domain here would cost and the
+// nameservers it keeps (quoteTransfer), or why it cannot move. country is
+// optional, as the buy check's: it prices for the contact the CLI will
+// use. It writes nothing.
+func (s *Server) handleAPIDomainTransferCheck(w http.ResponseWriter, r *http.Request) {
+ _, acct, ok := s.domainBuyAPIGate(w, r)
+ if !ok {
+ return
+ }
+ var in struct {
+ Name string `json:"name"`
+ Country string `json:"country"`
+ }
+ if !readJSONStrictLimit(w, r, &in, 8<<10) {
+ return
+ }
+ country, ref := s.quoteCountry(acct, in.Country)
+ if ref != nil {
+ writeDoorRefusalJSON(w, r, ref)
+ return
+ }
+ ctx, cancel := context.WithTimeout(r.Context(), 20*time.Second)
+ defer cancel()
+ tq, ref := s.quoteTransfer(ctx, acct, in.Name, country)
+ if ref != nil {
+ writeDoorRefusalJSON(w, r, ref)
+ return
+ }
+ writeJSON(w, 200, map[string]any{"domain": tq.Quote.Domain, "price": tq.Quote.Price, "currency": tq.Quote.Currency, "nameservers": tq.Nameservers})
+}
+
+// handleAPIDomainTransferStart is POST .../domains/transfers: it starts a
+// transfer in by name (startDomainTransfer, every check again; unlike the
+// browser's door no address need be attached) and answers its Checkout
+// link. The transfer code travels only in this body and is never in an
+// answer or a log line. A refusal the CLI can put right carries a code:
+// auth_code, contact, or price_changed with the price to confirm.
+func (s *Server) handleAPIDomainTransferStart(w http.ResponseWriter, r *http.Request) {
+ addr, acct, ok := s.domainBuyAPIGate(w, r)
+ if !ok {
+ return
+ }
+ var in struct {
+ Name string `json:"name"`
+ AuthCode string `json:"auth_code"`
+ Contact *registrar.Contact `json:"contact"`
+ ContactID string `json:"contact_id"`
+ Currency string `json:"currency"`
+ Price int64 `json:"price"`
+ }
+ if !readJSONStrictLimit(w, r, &in, 16<<10) {
+ return
+ }
+ ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
+ defer cancel()
+ sel, ref := s.apiContactSelection(ctx, acct, in.ContactID, in.Contact, PurchaseKindTransfer)
+ if ref != nil {
+ writeDoorRefusalJSON(w, r, ref)
+ return
+ }
+ p, checkout, changed, ref := s.startDomainTransfer(ctx, acct, in.Name, in.AuthCode, sel, addr, domainreg.Quote{Currency: in.Currency, Price: in.Price})
+ if changed != nil {
+ writeJSON(w, http.StatusConflict, map[string]any{"error": domainBuyStateRefusal("priceChanged", http.StatusConflict).Msg, "code": "price_changed", "domain": changed.Domain, "currency": changed.Currency, "price": changed.Price})
+ return
+ }
+ if ref != nil {
+ code := ""
+ if ref.Status == http.StatusUnprocessableEntity {
+ switch ref.Msg {
+ case domainBuyCopy["contactError"]:
+ code = "contact"
+ case domainTransferCopy["authCode"]:
+ code = "auth_code"
+ }
+ }
+ if code != "" {
+ writeJSON(w, ref.Status, map[string]string{"error": ref.Msg, "code": code})
+ return
+ }
+ writeDoorRefusalJSON(w, r, ref)
+ return
+ }
+ writeJSON(w, 200, map[string]any{"id": p.ID, "checkout_url": checkout, "state": p.State})
+}
+
type domainPurchaseReply struct {
ID string `json:"id"`
// Kind is "buy" or "transfer": a transfer's card draws its own stages.
diff --git a/internal/console/apidomainbuy_test.go b/internal/console/apidomainbuy_test.go
index 717dfb3de..587a227c4 100644
--- a/internal/console/apidomainbuy_test.go
+++ b/internal/console/apidomainbuy_test.go
@@ -4,8 +4,10 @@ import (
"context"
"encoding/json"
"io"
+ "log"
"net/http"
"net/url"
+ "os"
"strings"
"sync"
"testing"
@@ -271,6 +273,8 @@ func TestBuyDoorsAbsentOnHostClaimConsole(t *testing.T) {
for _, path := range []string{
"route POST /api/cli/accounts/{account}/domains/check",
"route POST /api/cli/accounts/{account}/domains/purchases",
+ "route POST /api/cli/accounts/{account}/domains/transfers/check",
+ "route POST /api/cli/accounts/{account}/domains/transfers",
"route GET /api/cli/accounts/{account}/domains/purchases/{id}",
"route GET /api/cli/accounts/{account}/domains/contacts",
"route POST /api/cli/accounts/{account}/domains/contacts",
@@ -764,3 +768,211 @@ func TestDomainsUnreadSplitsBrowserAndAPI(t *testing.T) {
t.Fatalf("page: %d %s", status, body)
}
}
+
+// ---- transfers in, Task 10: the CLI's transfer doors ----
+
+func transferAPIPath(f *purchaseFixture) string { return buyAPIPath(f) + "/transfers" }
+
+// transferStartBody is a start as the CLI sends it, with a new contact.
+func transferStartBody(t *testing.T, tf *transferFixture, edit func(map[string]any)) string {
+ t.Helper()
+ q := transferQuoteFor(tf.srv, tf.acct)
+ in := map[string]any{"name": "shop.com", "auth_code": testAuthCode, "contact": purchaseContact(), "currency": q.Currency, "price": q.Price}
+ if edit != nil {
+ edit(in)
+ }
+ b, err := json.Marshal(in)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return string(b)
+}
+
+// TestAPITransferCheckAndStart: the check prices the transfer and names the
+// nameservers it keeps, writing nothing; the start answers the Checkout
+// link, and its status is the purchase status door's, kind transfer. The
+// CLI transfers by name: no address need be attached. A refusal comes with
+// a code the CLI can put right (auth_code, contact, price_changed), another
+// account's claim is the neutral claim refusal, and the transfer code is
+// never in an answer or a log line.
+func TestAPITransferCheckAndStart(t *testing.T) {
+ logs := &lockedBuffer{}
+ log.SetOutput(logs)
+ t.Cleanup(func() { log.SetOutput(os.Stderr) })
+ tf := newTransferFixture(t)
+ f := tf.purchaseFixture
+ tok := buyToken(t, f)
+ var bodies []string
+ call := func(method, path, body string) (int, string) {
+ t.Helper()
+ status, b := buyRequest(t, f, method, path, tok, body)
+ bodies = append(bodies, b)
+ return status, b
+ }
+
+ status, b := call("POST", transferAPIPath(f)+"/check", `{"name":"SHOP.com"}`)
+ var quote struct {
+ Domain string `json:"domain"`
+ Price int64 `json:"price"`
+ Currency string `json:"currency"`
+ Nameservers []string `json:"nameservers"`
+ }
+ if err := json.Unmarshal([]byte(b), &quote); err != nil {
+ t.Fatalf("check %d %s: %v", status, b, err)
+ }
+ if status != 200 || quote.Domain != "shop.com" || quote.Price != 1200 || quote.Currency != "usd" ||
+ strings.Join(quote.Nameservers, " ") != "ns1.example-dns.test ns2.example-dns.test" {
+ t.Fatalf("check %d %s", status, b)
+ }
+ if n := tf.purchaseCount(t); n != 0 {
+ t.Fatalf("the check wrote %d purchase(s)", n)
+ }
+ // A refusal before payment, in plain words.
+ tf.reg.TransferChecks["shop.com"] = registrar.TransferCheck{Reason: "locked"}
+ if status, b := call("POST", transferAPIPath(f)+"/check", `{"name":"shop.com"}`); status != 422 || !strings.Contains(b, domainTransferNotNow["locked"]) {
+ t.Fatalf("locked check %d %s", status, b)
+ }
+ tf.reg.TransferChecks["shop.com"] = registrar.TransferCheck{Transferable: true, Cost: registrar.Money{Currency: "usd", Minor: 800}}
+
+ // Another account's claim is the same answer as a domain registered
+ // here: the neutral claim refusal, before any payment.
+ other := planAccount(t, tf.consoleFixture, 502)
+ adApp(t, tf.consoleFixture, other, "theirs")
+ adClaim(t, tf.consoleFixture, other, "theirs", "www.foreign.com")
+ adBought(t, tf.consoleFixture, other, "bought.com", time.Now().AddDate(1, 0, 0))
+ for _, name := range []string{"foreign.com", "bought.com"} {
+ tf.reg.TransferChecks[name] = registrar.TransferCheck{Transferable: true, Cost: registrar.Money{Currency: "usd", Minor: 800}}
+ }
+ sf, bf := call("POST", transferAPIPath(f)+"/check", `{"name":"foreign.com"}`)
+ sb, bb := call("POST", transferAPIPath(f)+"/check", `{"name":"bought.com"}`)
+ if sf != 409 || sf != sb || bf != strings.ReplaceAll(bb, "bought.com", "foreign.com") {
+ t.Fatalf("foreign %d %s, registered here %d %s: want the same neutral refusal", sf, bf, sb, bb)
+ }
+
+ // Refusals the CLI can put right, each with its code; none starts a
+ // purchase.
+ for _, tc := range []struct {
+ label, code string
+ edit func(map[string]any)
+ }{
+ {"no code", "auth_code", func(in map[string]any) { delete(in, "auth_code") }},
+ {"bad code", "auth_code", func(in map[string]any) { in["auth_code"] = "has space" }},
+ {"bad contact", "contact", func(in map[string]any) { c := purchaseContact(); c.Phone = "not-digits"; in["contact"] = c }},
+ {"both contacts", "contact", func(in map[string]any) { in["contact_id"] = "sc_x" }},
+ } {
+ status, b := call("POST", transferAPIPath(f), transferStartBody(t, tf, tc.edit))
+ if status != 422 || !strings.Contains(b, `"code":"`+tc.code+`"`) {
+ t.Fatalf("%s: %d %s", tc.label, status, b)
+ }
+ }
+ status, b = call("POST", transferAPIPath(f), transferStartBody(t, tf, func(in map[string]any) { in["price"] = 999 }))
+ var changed map[string]any
+ if err := json.Unmarshal([]byte(b), &changed); err != nil {
+ t.Fatal(err)
+ }
+ if status != 409 || changed["code"] != "price_changed" || changed["price"] != float64(1200) || changed["currency"] != "usd" || changed["domain"] != "shop.com" {
+ t.Fatalf("price changed %d %s", status, b)
+ }
+ if n := tf.purchaseCount(t); n != 0 {
+ t.Fatalf("refused starts wrote %d purchase(s)", n)
+ }
+
+ // The start: the Checkout link, and the record keeps the code and the
+ // nameservers.
+ status, b = call("POST", transferAPIPath(f), transferStartBody(t, tf, nil))
+ var started struct {
+ ID string `json:"id"`
+ CheckoutURL string `json:"checkout_url"`
+ State string `json:"state"`
+ }
+ if err := json.Unmarshal([]byte(b), &started); err != nil || status != 200 {
+ t.Fatalf("start %d %s %v", status, b, err)
+ }
+ p, err := tf.st.DomainPurchase(started.ID)
+ if err != nil || p == nil {
+ t.Fatalf("purchase %s: %v", started.ID, err)
+ }
+ info, err := tf.fake.PaymentCheckout(context.Background(), p.CheckoutSession)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if started.CheckoutURL != info.URL || started.State != "awaiting_payment" || p.Kind != PurchaseKindTransfer || p.AuthCode != testAuthCode ||
+ strings.Join(p.Nameservers, " ") != "ns1.example-dns.test ns2.example-dns.test" || p.AccountID != tf.acct.ID {
+ t.Fatalf("start %s, purchase %+v", b, p)
+ }
+ // Again: the same transfer resumes, its code not replaced.
+ status, b = call("POST", transferAPIPath(f), transferStartBody(t, tf, func(in map[string]any) { in["auth_code"] = "Other-code-1" }))
+ if status != 200 || !strings.Contains(b, `"id":"`+started.ID+`"`) {
+ t.Fatalf("resume %d %s", status, b)
+ }
+ if p, _ := tf.st.DomainPurchase(started.ID); p.AuthCode != testAuthCode {
+ t.Fatal("a resumed start replaced the code")
+ }
+ if n := tf.purchaseCount(t); n != 1 {
+ t.Fatalf("%d purchases, want 1", n)
+ }
+ // Its status is the purchase status door's.
+ status, b = call("GET", buyAPIPath(f)+"/purchases/"+started.ID, "")
+ if status != 200 || !strings.Contains(b, `"kind":"transfer"`) || !strings.Contains(b, `"state":"awaiting_payment"`) || !strings.Contains(b, `"stage":"awaiting"`) {
+ t.Fatalf("status %d %s", status, b)
+ }
+ for _, b := range bodies {
+ if strings.Contains(b, testAuthCode) {
+ t.Fatalf("an answer carries the transfer code: %s", b)
+ }
+ }
+ if strings.Contains(logs.String(), testAuthCode) {
+ t.Fatalf("transfer code logged:\n%s", logs.String())
+ }
+}
+
+// TestAPITransferOwnerOnlyServiceClosed: the transfer doors are a person's
+// and the owner's (a member and a service credential are refused before
+// any check), closed to every service role, behind the buy door's gate
+// (404 for the owner too with buying off) and not registered on a
+// host-claim console.
+func TestAPITransferOwnerOnlyServiceClosed(t *testing.T) {
+ tf := newTransferFixture(t)
+ f := tf.purchaseFixture
+ if err := f.st.AddMember(f.acct.ID, "member@example.com", RoleMember, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ doors := []struct{ path, body string }{
+ {"/check", `{"name":"shop.com"}`},
+ {"", transferStartBody(t, tf, nil)},
+ }
+ for _, tok := range []string{cliToken(t, f.consoleFixture, "member@example.com", "transfer-member"), serviceToken(t, f.st, f.acct.ID, "transfer-service", "kass", svcrole.Admin)} {
+ for _, d := range doors {
+ status, b := buyRequest(t, f, "POST", transferAPIPath(f)+d.path, tok, d.body)
+ if status != 404 && status != 403 && status != 401 {
+ t.Fatalf("%q: %d %s", d.path, status, b)
+ }
+ }
+ }
+ if len(f.reg.Calls) != 0 || tf.purchaseCount(t) != 0 {
+ t.Fatalf("refused doors reached admission: registrar %v, %d purchase(s)", f.reg.Calls, tf.purchaseCount(t))
+ }
+ tok := buyToken(t, f)
+ f.srv.cfg.DomainCatalog.DailyCap = 0
+ for _, d := range doors {
+ if status, b := buyRequest(t, f, "POST", transferAPIPath(f)+d.path, tok, d.body); status != 404 {
+ t.Fatalf("buying off %q: %d %s", d.path, status, b)
+ }
+ }
+ want := map[string]bool{
+ "POST /api/cli/accounts/{account}/domains/transfers/check": true,
+ "POST /api/cli/accounts/{account}/domains/transfers": true,
+ }
+ for _, d := range routeDecls {
+ if !want[d.Pattern] {
+ continue
+ }
+ delete(want, d.Pattern)
+ if d.Kind != kindCLI || d.Gate != gateNoHostClaim || !d.Allow.Empty() {
+ t.Errorf("%s: want a CLI door, gateNoHostClaim, closed to every service role", d.Pattern)
+ }
+ }
+ if len(want) != 0 {
+ t.Fatalf("not declared: %v", want)
+ }
+}
diff --git a/internal/console/domaintransfer_start.go b/internal/console/domaintransfer_start.go
index 6287581da..38172f05a 100644
--- a/internal/console/domaintransfer_start.go
+++ b/internal/console/domaintransfer_start.go
@@ -30,9 +30,11 @@ func transferPrice(tld domainreg.TLD, currency string) int64 {
}
// quoteTransfer checks that the account may transfer name in now and
-// prices it. Every refusal comes before any payment.
-func (s *Server) quoteTransfer(ctx context.Context, acct *Account, name string) (transferQuote, *doorRefusal) {
- return s.admitDomainTransfer(ctx, acct, name)
+// prices it, for country when given (the contact's; else the account's
+// currency or the catalog's default). Every refusal comes before any
+// payment.
+func (s *Server) quoteTransfer(ctx context.Context, acct *Account, name string, country ...string) (transferQuote, *doorRefusal) {
+ return s.admitDomainTransfer(ctx, acct, name, country...)
}
// admitDomainTransfer is admitDomainDoor plus a transfer's own checks, in
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go
index 80c4ff9ca..e3a1d90f0 100644
--- a/internal/console/routedecls.go
+++ b/internal/console/routedecls.go
@@ -896,6 +896,11 @@ var routeDecls = []routeDecl{
{Pattern: "POST /api/cli/accounts/{account}/domains/check", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainCheck},
{Pattern: "POST /api/cli/accounts/{account}/domains/purchases", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainPurchase},
{Pattern: "GET /api/cli/accounts/{account}/domains/purchases/{id}", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainPurchaseStatus},
+ // Transfers in (transfers in, Task 10): the check and the start, by
+ // name, behind the same gate; a transfer's status is the purchase
+ // status door above.
+ {Pattern: "POST /api/cli/accounts/{account}/domains/transfers/check", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainTransferCheck},
+ {Pattern: "POST /api/cli/accounts/{account}/domains/transfers", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainTransferStart},
// The point door's CLI twin (domainpoint.go): a person and the owner
// only, unlike the attach API it sits beside, so no service role.
{Pattern: "POST /api/cli/apps/{account}/{app}/domains/point", Kind: kindCLI, Gate: gateNoHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainPoint},
diff --git a/internal/console/svcroutes_test.go b/internal/console/svcroutes_test.go
index 4b494840d..804d45f72 100644
--- a/internal/console/svcroutes_test.go
+++ b/internal/console/svcroutes_test.go
@@ -251,6 +251,8 @@ var closedDoors = []string{
"GET /api/cli/accounts/{account}/domains/purchases/{id}",
"POST /api/cli/accounts/{account}/domains/check",
"POST /api/cli/accounts/{account}/domains/purchases",
+ "POST /api/cli/accounts/{account}/domains/transfers/check",
+ "POST /api/cli/accounts/{account}/domains/transfers",
// An account's domains are read by its people (members), and its saved
// contacts are the owner's personal data: no machine credential.
"GET /api/cli/accounts/{account}/domains",
@@ -474,6 +476,8 @@ var domainBuyDoors = []string{
"GET /api/cli/accounts/{account}/domains/purchases/{id}",
"POST /api/cli/accounts/{account}/domains/check",
"POST /api/cli/accounts/{account}/domains/purchases",
+ "POST /api/cli/accounts/{account}/domains/transfers/check",
+ "POST /api/cli/accounts/{account}/domains/transfers",
"POST /api/cli/apps/{account}/{app}/domains/point",
"POST /api/cli/system/domains/purchases/{id}/resolve",
}
@@ -1800,8 +1804,8 @@ func TestEveryClosedDoorRefusesAServiceCredential(t *testing.T) {
}
seen++
}
- if seen != len(closedDoors) || seen != 114 {
- t.Errorf("walked %d closed doors, want all %d (and 114 today: three domain purchase doors, the account's domains list, four saved-contact doors, the domain point door, the transfer resolve door, two managed admission doors, the fleet show door, two managed configuration doors, three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the instance label door, the fleet secrets key door, the two person link doors (list and unlink), the six home link doors, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, eleven system doors, three deployment-wide antivirus, the PDF status door, the media status door, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, two release authorize doors, four store-entitlement doors, two account plan doors, three platform grant doors, two billing problem doors, the billing revenue and payments doors, the billing house door, three account subdomain doors, the subdomain inventory, and the claimed source door)",
+ if seen != len(closedDoors) || seen != 116 {
+ t.Errorf("walked %d closed doors, want all %d (and 116 today: three domain purchase doors, two domain transfer doors, the account's domains list, four saved-contact doors, the domain point door, the transfer resolve door, two managed admission doors, the fleet show door, two managed configuration doors, three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the instance label door, the fleet secrets key door, the two person link doors (list and unlink), the six home link doors, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, eleven system doors, three deployment-wide antivirus, the PDF status door, the media status door, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, two release authorize doors, four store-entitlement doors, two account plan doors, three platform grant doors, two billing problem doors, the billing revenue and payments doors, the billing house door, three account subdomain doors, the subdomain inventory, and the claimed source door)",
seen, len(closedDoors))
}
}
diff --git a/parity/cli.tsv b/parity/cli.tsv
index 2cbeed05a..ff0808e11 100644
--- a/parity/cli.tsv
+++ b/parity/cli.tsv
@@ -77,6 +77,7 @@ domains list customer - - - - -
domains paths customer - - - - -
domains placements customer - - - - -
domains point customer - - - - -
+domains transfer customer - - - - -
domains verify customer - - - - -
economics backhaul operator - - - - -
economics bill operator - - - - -
diff --git a/parity/parity.tsv b/parity/parity.tsv
index 355620dee..714059629 100644
--- a/parity/parity.tsv
+++ b/parity/parity.tsv
@@ -88,7 +88,7 @@ domains-attach domains both domains attach ; domains detach POST /a/{sqid}/apps/
domains-verify domains partial domains verify POST /a/{sqid}/apps/{app}/domains/attach There is no Verify button; attaching again verifies.
domains-buy domains both domains check ; domains buy GET /a/{sqid}/domains/buy ; POST /a/{sqid}/domains/buy/check ; POST /a/{sqid}/domains/buy ; GET /a/{sqid}/domains/purchases/{id} ; GET /a/{sqid}/domains/purchases/{id}/status ; GET /a/{sqid}/apps/{app}/domains/buy ; POST /a/{sqid}/apps/{app}/domains/check ; POST /a/{sqid}/apps/{app}/domains/buy ; GET /a/{sqid}/apps/{app}/domains/purchases/{id} ; GET /a/{sqid}/apps/{app}/domains/purchases/{id}/status The app-scoped routes only redirect to the account's.
domains-contacts domains both domains contacts list ; domains contacts add ; domains contacts edit ; domains contacts remove POST /a/{sqid}/domains/contacts ; POST /a/{sqid}/domains/contacts/{id} ; POST /a/{sqid}/domains/contacts/{id}/remove Saved contacts are added, edited and removed on the Domains page and with domains contacts; a purchase with no contact named uses the most recently used one.
-domains-transfer domains console-only GET /a/{sqid}/domains/transfer/{domain} ; POST /a/{sqid}/domains/transfer/{domain} Moving a domain registered elsewhere here (Move to Carloku): the form and its start; the move's card is the purchase card. No CLI command yet.
+domains-transfer domains both domains transfer GET /a/{sqid}/domains/transfer/{domain} ; POST /a/{sqid}/domains/transfer/{domain} Moving a domain registered elsewhere here (Move to Carloku): the form and its start, and domains transfer, which moves one by name; the move's card is the purchase card, and the CLI waits on its status.
domains-point domains both domains point POST /a/{sqid}/apps/{app}/domains/point
domains-paths domains gap domains paths wp-settings
domains-placements domains gap domains placements wp-settings
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl
index 1cc1f793f..5af17fda6 100644
--- a/testdata/clireg-golden.jsonl
+++ b/testdata/clireg-golden.jsonl
@@ -248,14 +248,16 @@
{"case":"domains placements | -h","argv":["domains","placements","-h"],"exit":0,"stdout":"","stderr":"usage: carlos domains placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [--account <a>] [--account-id <id>] [--console <origin>] <hostname>\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app the hostname belongs to\n --catchall also serve every one-label name under the domain from the same instances. set it only when the domain is created. it requires --wildcard\n --console <string> console to read through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --set <value> give the region and the instance that serves the hostname there, as region=instance. repeat this for each region\n --wildcard use one wildcard certificate for the domain. set it only when the domain is created. it needs a CNAME. the message says which CNAME is missing\n"}
{"case":"domains point | --zz-unknown-flag","argv":["domains","point","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos domains point <domain> --app <a> [--account <a>] [--account-id <id>] [--console <origin>]\nflags:\n --account <string> account (sqid or name)\n --account-id <string> account sqid, matched as a sqid only\n --app, -a <string> app to point the domain at\n --console <string> console to use (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\nflag provided but not defined: -zz-unknown-flag\n"}
{"case":"domains point | -h","argv":["domains","point","-h"],"exit":0,"stdout":"","stderr":"usage: carlos domains point <domain> --app <a> [--account <a>] [--account-id <id>] [--console <origin>]\nflags:\n --account <string> account (sqid or name)\n --account-id <string> account sqid, matched as a sqid only\n --app, -a <string> app to point the domain at\n --console <string> console to use (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
+{"case":"domains transfer | --zz-unknown-flag","argv":["domains","transfer","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos domains transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\nflags:\n --account <string> account (sqid or name)\n --account-id <string> account sqid, matched as a sqid only\n --auth-code <string> the transfer code from the domain’s current registrar, or - to read it from stdin\n --console <string> console to use (default: the only logged-in one)\n --contact <string> saved contact to use when registering the domain; list contacts with carlos domains contacts\n --contact-file <string> JSON file containing your contact details\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --no-wait print the checkout link and return without waiting\n --yes confirm the transfer without prompting\nflag provided but not defined: -zz-unknown-flag\n"}
+{"case":"domains transfer | -h","argv":["domains","transfer","-h"],"exit":0,"stdout":"","stderr":"usage: carlos domains transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [--account <a>] [--account-id <id>] [--console <origin>]\nflags:\n --account <string> account (sqid or name)\n --account-id <string> account sqid, matched as a sqid only\n --auth-code <string> the transfer code from the domain’s current registrar, or - to read it from stdin\n --console <string> console to use (default: the only logged-in one)\n --contact <string> saved contact to use when registering the domain; list contacts with carlos domains contacts\n --contact-file <string> JSON file containing your contact details\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --no-wait print the checkout link and return without waiting\n --yes confirm the transfer without prompting\n"}
{"case":"domains verify | --zz-unknown-flag","argv":["domains","verify","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos domains verify --app <a> [--channel <c>] [--account <a>] [--account-id <id>] [--console <origin>] <hostname>\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app the hostname belongs to\n --channel <string> channel a first-route hostname serves (only needed when the app follows several)\n --console <string> console to verify through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
{"case":"domains verify | -h","argv":["domains","verify","-h"],"exit":0,"stdout":"","stderr":"usage: carlos domains verify --app <a> [--channel <c>] [--account <a>] [--account-id <id>] [--console <origin>] <hostname>\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app the hostname belongs to\n --channel <string> channel a first-route hostname serves (only needed when the app follows several)\n --console <string> console to verify through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
-{"case":"domains | --help","argv":["domains","--help"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
-{"case":"domains | --zz-unknown-flag","argv":["domains","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
-{"case":"domains | -h","argv":["domains","-h"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
-{"case":"domains | bare","argv":["domains"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
-{"case":"domains | help","argv":["domains","help"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
-{"case":"domains | zz-unknown","argv":["domains","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
+{"case":"domains | --help","argv":["domains","--help"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n move a domain registered elsewhere here. it keeps the\n nameservers it uses today, so its DNS and email don’t\n change. --auth-code - reads the transfer code from stdin.\n waits until the move is done or fails, which can take up\n to five days. owners only\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
+{"case":"domains | --zz-unknown-flag","argv":["domains","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n move a domain registered elsewhere here. it keeps the\n nameservers it uses today, so its DNS and email don’t\n change. --auth-code - reads the transfer code from stdin.\n waits until the move is done or fails, which can take up\n to five days. owners only\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
+{"case":"domains | -h","argv":["domains","-h"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n move a domain registered elsewhere here. it keeps the\n nameservers it uses today, so its DNS and email don’t\n change. --auth-code - reads the transfer code from stdin.\n waits until the move is done or fails, which can take up\n to five days. owners only\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
+{"case":"domains | bare","argv":["domains"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n move a domain registered elsewhere here. it keeps the\n nameservers it uses today, so its DNS and email don’t\n change. --auth-code - reads the transfer code from stdin.\n waits until the move is done or fails, which can take up\n to five days. owners only\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
+{"case":"domains | help","argv":["domains","help"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n move a domain registered elsewhere here. it keeps the\n nameservers it uses today, so its DNS and email don’t\n change. --auth-code - reads the transfer code from stdin.\n waits until the move is done or fails, which can take up\n to five days. owners only\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
+{"case":"domains | zz-unknown","argv":["domains","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos domains <check|buy|transfer|attach|verify|detach|list|point|contacts|paths|placements> [flags]\n\n check <name> [--country <cc>] [flags]\n check availability and the price for one year\n buy <name> --app <a> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy <name> --not-yet [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n buy a domain and wait for it to serve the app. with\n --not-yet, buy a domain without pointing it at an app yet.\n buy needs one of --app or --not-yet. --contact <id>\n registers it to that saved contact; with neither contact\n flag, buy uses the one used last\n\n transfer <name> --auth-code <code|-> [--contact <id> | --contact-file contact.json] [--yes] [--no-wait] [flags]\n move a domain registered elsewhere here. it keeps the\n nameservers it uses today, so its DNS and email don’t\n change. --auth-code - reads the transfer code from stdin.\n waits until the move is done or fails, which can take up\n to five days. owners only\n attach --app <a> [--route <r>] [--wildcard] [--catchall] [--platform] [flags] <hostname>\n claim a customer's hostname for the app, pointed at\n --route (default: the app's single instance record, if it\n has exactly one — otherwise --route is required).\n --wildcard/--catchall are capability flips: naming either\n one changes it, an unset flag leaves it as it was.\n --platform attaches a hostname in this deployment's own\n domains. Platform operators only.\n Where the deployment requires proof of control, the\n hostname is not served until you add the TXT record\n attach prints.\n attach --app <a> '*.<parent>'\n an instance catch-all: each of the app's instances also\n answers at <label>.<parent>, where <label> is its host's\n first label. <parent> must already be attached to an app\n in this account. Signed-in people only; takes no other\n flag. Detach it with: detach --app <a> '*.<parent>'.\n verify --app <a> [--channel <c>] [flags] <hostname>\n check the TXT record and, once it is there, make the\n hostname live. --channel is for a hostname that will be\n the app's first route, when the app follows several.\n detach --app <a> [flags] <hostname>\n release a hostname claim\n list [--app <a> | --all] [flags]\n an app's hostname claims, joined to the fleet's own\n readings sweep (DNS/CERT-EXPIRES/WILDCARD/CATCHALL/DELEGATION).\n without --app, the configured app or the account's only\n app. with --all, or when no app is found, every domain\n the account uses: bought here, being bought, or\n registered elsewhere, each with its addresses\n point <domain> --app <a> [flags]\n point a domain bought here at an app. its domain and its\n www serve the app. owners only\n contacts [list | add --file contact.json | edit <id> --file contact.json | remove <id>] [flags]\n the contacts saved for registering domains. owners only\n paths --app <a> [flags] <hostname>\n the leading path segments this hostname's traffic is split\n by, as PUBLISHED. Read-only: the platform that owns the\n hostname republishes the whole map, so there is no verb\n here that writes one.\n placements --app <a> [--set <region>=<instance>]... [--wildcard] [--catchall] [flags] <hostname>\n without --set, shows which instance serves the hostname in\n each region, whether it is ready, and the addresses to\n point DNS at. with --set, makes the hostname a regional\n domain. each region serves it from the instance named for\n it, and a request is never sent to another region. give\n the whole set every time. --wildcard and --catchall take\n effect only when the domain is created.\n\n --account <a> account (sqid or name; default \"ops\")\n --account-id <id> account sqid, matched as a sqid ONLY\n --console <origin> console to act through (default: the only logged-in one)\n\nSigned-in only (carlos auth login): a claim is a console-authorized write —\nthe console checks the hostname against the deploy's deny list, resolves the\nroute, and writes it. The hostname comes live on the box that owns the route\nat its next domains pass.\n"}
{"case":"economics backhaul | --zz-unknown-flag","argv":["economics","backhaul","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos economics backhaul [--period mtd|last|7d] [--console <origin>]\n\nShows what serving through region edges costs the platform this period:\nthe part of every account's egress that was backhauled from its home box\n(usage.EdgeRow's hop subset — inside the egress totals, never on top),\npriced at the rate card's inter-region $/GB (the extra leg; the home box's\nbytes are already egress) and ABSORBED — it is in nobody's bill (#284).\nOperator only; a non-operator's token gets the same bare 404 an unknown\nroute gets.\nflags:\n --console <string> console to ask (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --period <string> mtd (default), last, or 7d\n"}
{"case":"economics backhaul | -h","argv":["economics","backhaul","-h"],"exit":0,"stdout":"","stderr":"usage: carlos economics backhaul [--period mtd|last|7d] [--console <origin>]\n\nShows what serving through region edges costs the platform this period:\nthe part of every account's egress that was backhauled from its home box\n(usage.EdgeRow's hop subset — inside the egress totals, never on top),\npriced at the rate card's inter-region $/GB (the extra leg; the home box's\nbytes are already egress) and ABSORBED — it is in nobody's bill (#284).\nOperator only; a non-operator's token gets the same bare 404 an unknown\nroute gets.\nflags:\n --console <string> console to ask (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --period <string> mtd (default), last, or 7d\n"}
{"case":"economics bill | --zz-unknown-flag","argv":["economics","bill","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos economics bill --month <YYYY-MM> --total <usd> [--line Service=usd ...] [--basis account|whole] [--console <origin>]\n carlos economics backhaul [--period mtd|last|7d] [--console <origin>]\n\nRecords one month's AWS bill for the economics dashboard. Operator only: the\nconsole answers a non-operator's token with the same bare 404 it gives an\nunknown route (it must not be probeable), so \"not found\" here almost always\nmeans your account lacks the fleet-operator bit.\n\nA manual entry always overwrites whatever the console already holds for that\nmonth — a previous Cost Explorer pull or an earlier manual entry alike.\nflags:\n --basis <string> what the total covers: account (the whole account, which runs only CARLOS) or whole (the whole account, CARLOS and other things)\n --console <string> console to record through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --line <value> one line item, repeatable: Service=usd\n --month <string> billing month, YYYY-MM (required)\n --total <float> invoice total in US dollars (required)\n"}