package auth import ( "encoding/json" "io" "net/http" "strings" "sync" "time" ) const defaultFrontierTemplate = "https://launcher.finalfantasyxiv.com/v740/index.html?rc_lang={0}&time={1}" var ( templateOnce sync.Once frontierTpl string ) // frontierReferer builds the Referer header value SE's login page expects, // e.g. https://launcher.finalfantasyxiv.com/v740/index.html?rc_lang=en_us&time=2026-10-10-12-34 func frontierReferer() string { templateOnce.Do(func() { frontierTpl = fetchFrontierTemplate() }) tpl := strings.ReplaceAll(frontierTpl, "{0}", "en_us") return strings.ReplaceAll(tpl, "{1}", time.Now().UTC().Format("2006-01-02-15-04")) } func fetchFrontierTemplate() string { client := &http.Client{Timeout: 5 * time.Second} resp, err := client.Get("https://kamori.goats.dev/Launcher/GetLauncherClientConfig") if err != nil { return defaultFrontierTemplate } defer resp.Body.Close() var cfg struct { FrontierUrl string `json:"frontierUrl"` } body, _ := io.ReadAll(resp.Body) if err := json.Unmarshal(body, &cfg); err != nil || cfg.FrontierUrl == "" { return defaultFrontierTemplate } return cfg.FrontierUrl }