{"modulePath":"github.com/GoCodeAlone/workflow-plugin-hover","version":"v0.4.2","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package hoverclient\n\nPackage hoverclient implements the Hover DNS provider client.\n\nHover ships no official API. This package mimics the browser-side authentication flow exposed by Hover's signin UI:\n\n 1. POST [https://www.hover.com/signin/auth.json](https://www.hover.com/signin/auth.json) (username, password).\n 2. POST [https://www.hover.com/signin/auth2.json](https://www.hover.com/signin/auth2.json) (code) when MFA is required.\n 3. Subsequent requests carry the session cookie jar.\n\nTOTP codes are RFC 6238 (HMAC-SHA1, 30s window, 6 digits).\n\n## Variables\n\n```go\nvar ErrEmptyNameservers = errors.New(\"hover: delegation read returned 0 nameservers (verify field shape)\")\n```\nErrEmptyNameservers is returned by GetDomainDelegation when the parsed response has zero nameservers. Converts the silent-thrash failure mode (empty → Diff says NeedsUpdate forever → re-PUT loop) into a loud, single-iteration error visible at the first wfctl plan.\n\n## Types\n\n```go\ntype Client struct {\n\tUserAgent string\n\t// contains filtered or unexported fields\n}\n```\nClient is a Hover account-portal client. Concurrency-safe; the underlying cookie jar serialises across goroutines via mu.\n\n```go\nfunc NewClient(creds Credentials, httpClient *http.Client) (*Client, error)\n```\nNewClient returns a fresh Client. Pass http=nil for an internal jar-backed http.Client. Tests inject a stub to redirect requests.\n\n```go\nfunc (c *Client) CreateRecord(ctx context.Context, domainID string, rec DNSRecord) (*DNSRecord, error)\n```\nCreateRecord adds a new DNS record for the domain.\n\n```go\nfunc (c *Client) DeleteRecord(ctx context.Context, recordID string) error\n```\nDeleteRecord removes a record by ID.\n\n```go\nfunc (c *Client) GetDomain(ctx context.Context, domain string) (*Domain, error)\n```\nGetDomain returns the full Domain struct (including the hover-assigned ID) for the named zone. The ID is required when creating new records via CreateRecord; the human-readable name is not accepted by the POST /api/dns endpoint.\n\n```go\nfunc (c *Client) GetDomainDelegation(ctx context.Context, domainName string) (*DomainDelegation, error)\n```\nGetDomainDelegation fetches the registrar-level nameserver delegation for the named domain via the control-panel API (same endpoint family as the PUT used by SetNameservers — more likely to surface nameservers reliably than the DNS-records-oriented /api/domains/\\\u003cname\u003e/dns endpoint).\n\nReturns ErrEmptyNameservers if the parsed response has zero nameservers. This loud-on-empty behavior is intentional: it converts the silent re-apply thrash failure mode (empty → Diff says NeedsUpdate forever) into a single-iteration error visible at first wfctl plan.\n\n```go\nfunc (c *Client) ListDomains(ctx context.Context) ([]Domain, error)\n```\nListDomains fetches every domain in the authenticated account via the account-level GET /api/domains endpoint. The returned slice is the inverse-key of the SetNameservers / GetDomainDelegation / GetDomain surface (which all operate on a single named zone) — callers iterate the list to drive cross-zone operations like IaCProviderEnumerator.EnumerateAll(\"infra.dns\").\n\nCSRF is not required for GET requests under Hover's API; ensureLogin is still called so the session cookie is fresh.\n\n```go\nfunc (c *Client) ListRecords(ctx context.Context, domain string) ([]DNSRecord, error)\n```\nListRecords returns records for the named zone. Caller MUST pass the apex domain (e.g. \"example.com\").\n\n```go\nfunc (c *Client) Login(ctx context.Context) error\n```\nLogin performs a full authentication cycle against Hover's control panel. It is safe to call when already authenticated — it re-authenticates only when the session is older than sessionStaleAfter (1 hour). Safe for concurrent use; the internal mutex serialises calls.\n\nThe underlying auth flow follows Hover's current React signin UI:\n\n 1. POST [https://www.hover.com/signin/auth.json](https://www.hover.com/signin/auth.json) with username + password.\n 2. If the response status is \"need\\_2fa\", POST /signin/auth2.json with the current TOTP code.\n 3. Session cookies are stored in the jar for subsequent API calls.\n\n```go\nfunc (c *Client) SetNameservers(ctx context.Context, domainName string, ns []string) error\n```\nSetNameservers updates the registrar-level nameservers for a domain via Hover's control-panel API.\n\nLock discipline: holds c.mu for the entire auth → CSRF fetch → PUT sequence. This eliminates the TOCTOU window between auth-check and PUT (another goroutine cannot re-auth and invalidate the CSRF token between the two requests).\n\nTrade-off: any concurrent caller using the same \\*Client blocks for the full duration of the held-lock sequence. Worst case (session is stale and re-auth fires inside ensureLoginLocked):\n\n  - POST /signin/auth.json (credentials)\n  - POST /signin/auth2.json (TOTP code, only if MFA enabled)\n  - GET /control\\_panel/domain/\\\u003cname\u003e (CSRF for the API write)\n  - PUT /api/control\\_panel/domains/domain-\\\u003cname\u003e\n\nUp to ~180s at the 30s default per-request timeout when re-auth is needed; ~60s on the warm-session path (CSRF GET + PUT). Acceptable for the field-test scope (single goroutine, one delegation resource). Future: cache CSRF at session granularity if mixed-resource throughput becomes a concern.\n\n```go\nfunc (c *Client) UpdateRecord(ctx context.Context, recordID string, rec DNSRecord) error\n```\nUpdateRecord PATCHes an existing record's content (and TTL when \u003e 0).\n\n```go\ntype Credentials struct {\n\tUsername   string\n\tPassword   string\n\tTOTPSecret TOTPSecret\n}\n```\nCredentials carries the operator-provided login material.\n\n```go\ntype DNSRecord struct {\n\tID      string `json:\"id,omitempty\"`\n\tType    string `json:\"type\"`\n\tName    string `json:\"name\"`\n\tContent string `json:\"content\"`\n\tTTL     int    `json:\"ttl,omitempty\"`\n}\n```\nDNSRecord mirrors Hover's internal API record shape.\n\n```go\ntype Domain struct {\n\tID      string      `json:\"id\"`\n\tName    string      `json:\"domain_name\"`\n\tRecords []DNSRecord `json:\"entries\"`\n}\n```\nDomain is the API shape returned by GET /api/domains.\n\n```go\ntype DomainDelegation struct {\n\tID          string   `json:\"id\"`\n\tName        string   `json:\"domain_name\"`\n\tNameservers []string `json:\"nameservers\"`\n}\n```\nDomainDelegation is the response shape of GET /api/control\\_panel/domains/domain-\\\u003cname\u003e. Distinct from Domain (which represents the /api/domains/\\\u003cname\u003e/dns shape with Records) to avoid ambiguity over which fields are populated by which endpoint.\n\nTentative envelope per design A6: flat object, not wrapped in {\"domains\":\\[...]}. First field-test call must confirm this shape; if Hover returns a different envelope the implementer pauses and amends the design before proceeding.\n\n```go\ntype TOTPSecret struct {\n\t// contains filtered or unexported fields\n}\n```\nTOTPSecret holds a decoded HOTP key. Construct via ParseBase32.\n\n```go\nfunc ParseBase32(seed string) (TOTPSecret, error)\n```\nParseBase32 parses a Google-Authenticator-style base32 seed (case- insensitive, padding optional) into a TOTPSecret. Spaces are stripped so users can paste from the Hover 2FA setup dialog.\n\n```go\nfunc (s TOTPSecret) Code() string\n```\nCode returns the 6-digit code for the current wall-clock time.\n\n```go\nfunc (s TOTPSecret) CodeAt(t int64) string\n```\nCodeAt returns the 6-digit code for the given Unix time t (seconds). 30-second step per RFC 6238 §4. Pure HMAC-SHA1 — no external deps.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-hover/pkg/hoverclient","name":"hoverclient","synopsis":"Package hoverclient implements the Hover DNS provider client.","isRedistributable":true}
