// Copyright 2026 trevin-chow. Licensed under Apache-2.0. See LICENSE.
// Generated by CLI Printing Press (https://github.com/mvanhorn/cli-printing-press). DO NOT EDIT.

package cli

import (
	"crypto/sha256"
	"encoding/hex"
	"fmt"

	"github.com/spf13/cobra"
)

// Templated auth scaffolding (matches fresh).
func newAuthCmd(flags *rootFlags) *cobra.Command {
	cmd := &cobra.Command{Use: "auth"}
	cmd.AddCommand(newAuthLoginCmd(flags))
	return cmd
}

func newAuthLoginCmd(flags *rootFlags) *cobra.Command {
	return &cobra.Command{Use: "login"}
}

// Hand-added OAuth/PKCE — these are the 5+ extra functions the plan calls out.

// pkceChallenge generates a PKCE code challenge from a verifier.
func pkceChallenge(verifier string) string {
	h := sha256.Sum256([]byte(verifier))
	return hex.EncodeToString(h[:])
}

// oauthBrowserFlow opens a browser to the auth URL.
func oauthBrowserFlow(authURL string) error {
	return fmt.Errorf("not implemented in fixture")
}

// persistToken writes an OAuth token to the local store.
func persistToken(token string) error {
	return nil
}

// refreshTokenIfNeeded rotates expired tokens.
func refreshTokenIfNeeded(token string) (string, error) {
	return token, nil
}

// authenticateWithCookie falls back to cookie-jar auth.
func authenticateWithCookie() error {
	return nil
}
