{"modulePath":"github.com/GoCodeAlone/workflow-plugin-hover","version":"v0.6.4","isLatest":true,"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 ErrBotChallenge = errors.New(\"hover: Imperva/bot challenge blocked the browser session — check network or rotate browser profile\")\n```\nErrBotChallenge is returned when Imperva (or another bot-protection layer) blocks the browser session: clearance cookies never arrive, or the login endpoint returns a persistent access-denied response. Operators should check network egress rules or rotate the browser profile.\n\n```go\nvar ErrBrowserBackendUnavailable = errors.New(\"hover: browser backend not yet available for this operation (Task 4)\")\n```\nErrBrowserBackendUnavailable is returned by browserBackend write operations that are not yet implemented (Task 4). Callers should treat this as a \"not yet implemented via browser\" signal.\n\n```go\nvar ErrChromeUnavailable = errors.New(\"hover: no Chrome binary found; install Chrome or set HOVER_BROWSER_DOWNLOAD=true\")\n```\nErrChromeUnavailable is returned when no Chrome binary can be found and BrowserOptions.Download is false. Install Chrome or set HOVER\\_BROWSER\\_DOWNLOAD=true to enable automatic download.\n\n```go\nvar ErrEmail2FARequired = errors.New(\"hover: account uses email/non-TOTP 2FA — configure an authenticator app (TOTP) on the account and supply totp_secret, or pre-trust this browser profile\")\n```\nErrEmail2FARequired is returned when Hover reports need\\_2fa but no TOTP secret is configured on the Credentials. This means the account uses email-OTP or another non-TOTP second factor. Configure a TOTP authenticator app on the account and supply the base32 seed as totp\\_secret.\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```go\nvar ErrForwardNotFound = errors.New(\"hover: forward not found\")\n```\nErrForwardNotFound is returned when Hover has no root forward configured.\n\n```go\nvar ErrSigninThrottled = errors.New(\"hover: signin throttled\")\n```\nErrSigninThrottled is returned internally when Hover starts rate-limiting credential signin. Callers see it wrapped in ErrBotChallenge with an operator-facing cooldown message.\n\n## Types\n\n```go\ntype BrowserOptions struct {\n\tPath       string\n\tDownload   bool\n\tHeadless   bool\n\tProfileDir string\n\tTimeout    time.Duration\n}\n```\nBrowserOptions controls the local Chrome instance used for live Hover access.\n\n```go\nfunc BrowserOptionsFromEnv() (BrowserOptions, error)\n```\nBrowserOptionsFromEnv returns BrowserOptions using HOVER\\_BROWSER\\_\\* env aliases.\n\n```go\nfunc DefaultBrowserOptions() BrowserOptions\n```\nDefaultBrowserOptions returns conservative runtime defaults for Chrome.\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 httpClient=nil for the browser backend (production path — Chrome drives Imperva clearance + login). Pass a non-nil \\*http.Client to select the HTTP backend; tests inject a stub to redirect requests without launching Chrome.\n\n```go\nfunc NewClientWithOptions(creds Credentials, httpClient *http.Client, opts ClientOptions) (*Client, error)\n```\nNewClientWithOptions returns a Client with explicit runtime options. opts.Browser is used when httpClient is nil (browser backend); it is ignored when httpClient is non-nil (HTTP backend selected).\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) GetForward(ctx context.Context, domainName string) (*DomainForward, error)\n```\nGetForward returns Hover's root web-forwarding target for a domain.\n\n```go\nfunc (c *Client) GetTransferLock(ctx context.Context, domainName string) (bool, error)\n```\nGetTransferLock returns the registrar transfer-lock state for a domain.\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\nOn the HTTP backend the 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) SetForward(ctx context.Context, domainName string, forward DomainForward) error\n```\nSetForward updates Hover's root web-forwarding target for a domain.\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) SetTransferLock(ctx context.Context, domainName string, locked bool) error\n```\nSetTransferLock updates Hover's registrar transfer-lock setting.\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 ClientOptions struct {\n\tBrowser BrowserOptions\n}\n```\nClientOptions configures a Client beyond credentials. Zero value is valid; individual fields fall back to defaults.\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\tNameservers []string    `json:\"nameservers\"`\n\tLocked      string      `json:\"locked\"`\n}\n```\nDomain is the API shape returned by GET /api/domains.\n\n```go\nfunc (d *Domain) UnmarshalJSON(data []byte) error\n```\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 DomainForward struct {\n\tDomain  string `json:\"domain\"`\n\tURL     string `json:\"url\"`\n\tStealth bool   `json:\"stealth\"`\n}\n```\nDomainForward is Hover's account-level web forwarding state for a domain.\n\n```go\ntype LiveAuthProbeResult struct {\n\tLoginSucceeded    bool\n\tClearanceCookies  []string\n\tGoHTTPReuseViable bool\n\tDomainCount       int\n}\n```\nLiveAuthProbeResult captures the live Hover browser-auth viability signal.\n\n```go\nfunc ProbeLiveBrowserAuth(ctx context.Context, creds Credentials, opts BrowserOptions) (LiveAuthProbeResult, error)\n```\nProbeLiveBrowserAuth exercises real Chrome against Hover. It is intended for opt-in live tests only; it never logs credentials or TOTP material.\n\n```go\nfunc (r LiveAuthProbeResult) ClearanceCookieNames() []string\n```\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}
