/**
 * LogtoConfig
 *
 * Logto 인증 및 OAuth 클라이언트/서버(M2M) 기능을 위한 환경설정 객체입니다.
 * 각 서비스(OAuthClient, LogtoM2MClient 등)에서 DI를 통해 주입받은 환경변수 기반으로 설정됩니다.
 *
 * 주요 필드 설명:
 * - endpoint: Logto 인증 서버의 엔드포인트 URL (예: https://auth.example.com/oidc)
 * - appId: Logto 애플리케이션의 Client ID
 * - appSecret: Logto 애플리케이션의 Client Secret
 * - grantType: OAuth 인증 플로우에서 사용할 Grant Type (GrantType enum 참고)
 * - scopes: 요청할 OAuth 스코프 목록 (예: ['openid', 'profile', 'email'])
 * - resources: 접근할 리소스 서버 목록 (예: ['https://api.example.com'])
 * - prompt: 인증 요청 시 사용할 prompt 파라미터 (Prompt enum 참고)
 * - includeReservedScopes: Logto의 예약 스코프 포함 여부 (일반적으로 false, 필요시 true)
 * - redirectUri: 인증 후 리다이렉트될 URI (Authorization Code 플로우에서 필수)
 *
 * 예시:
 * ```ts
 * const config: LogtoConfig = {
 *   endpoint: 'https://auth.example.com/oidc',
 *   appId: 'my-client-id',
 *   appSecret: 'my-client-secret',
 *   grantType: GrantType.AuthorizationCode,
 *   scopes: ['openid', 'profile', 'email'],
 *   resources: ['https://api.example.com'],
 *   prompt: Prompt.Login,
 *   redirectUri: 'https://myapp.com/callback',
 * };
 * ```
 */
export type LogtoConfig = {
    /** Logto 인증 서버의 엔드포인트 URL (예: https://auth.example.com/oidc) */
    endpoint: string;
    /** Logto 애플리케이션의 Client ID */
    appId: string;
    /** OAuth 인증 플로우에서 사용할 Grant Type (GrantType enum 참고) */
    grantType: GrantType;
    /** Logto 애플리케이션의 Client Secret */
    appSecret: string;
    /** 요청할 OAuth 스코프 목록 (예: ['openid', 'profile', 'email']) */
    scopes?: string[];
    /** 접근할 리소스 서버 목록 (예: ['https://api.example.com']) */
    resources?: string[];
    /** 인증 요청 시 사용할 prompt 파라미터 (Prompt enum 참고) */
    prompt?: Prompt;
    /** Logto의 예약 스코프 포함 여부 (일반적으로 false, 필요시 true) */
    includeReservedScopes?: boolean;
    /** 인증 후 리다이렉트될 URI (Authorization Code 플로우에서 필수) */
    redirectUri?: string;
};

/**
 * Prompt
 *
 * 인증 요청 시 prompt 파라미터로 사용할 값의 Enum.
 * - None: 사용자 상호작용 없이 인증 시도
 * - Consent: 동의 화면 강제 표시
 * - Login: 로그인 화면 강제 표시
 */
export enum Prompt {
    None = "none",
    Consent = "consent",
    Login = "login",
}

/**
 * GrantType
 *
 * OAuth 인증 플로우에서 사용할 Grant Type의 Enum.
 * - AuthorizationCode: 일반적인 사용자 인증(프론트엔드/백엔드 연동)
 * - ClientCredentials: 서버 간(M2M) 인증
 * - RefreshToken: 리프레시 토큰을 통한 토큰 갱신
 */
export enum GrantType {
    AuthorizationCode = 'authorization_code',
    ClientCredentials = 'client_credentials',
    RefreshToken = 'refresh_token',
}

/**
 * LogtoVerifierConfig
 *
 * Stateless 모드에서 토큰 검증에 필요한 설정입니다.
 * - jwksUri: JWKS 엔드포인트 URI
 * - issuer: 토큰 발급자(issuer)
 */
export interface LogtoVerifierConfig {
    /** JWKS 엔드포인트 URI */
    jwksUri: string;
    /** 토큰 발급자 (issuer) */
    issuer: string;
}

/**
 * LogtoOAuthConfig
 *
 * OAuth 클라이언트 설정입니다.
 * Authorization Code 플로우에서 사용됩니다.
 */
export interface LogtoOAuthConfig {
    /** Logto 인증 서버의 엔드포인트 URL */
    endpoint: string;
    /** Logto 애플리케이션의 Client ID */
    clientId: string;
    /** Logto 애플리케이션의 Client Secret */
    clientSecret: string;
    /** 접근할 리소스 서버 목록 */
    resources: string[];
    /** 요청할 OAuth 스코프 목록 */
    scopes: string[];
    /** 인증 요청 시 사용할 prompt 파라미터 */
    prompt: Prompt;
    /** 인증 후 리다이렉트될 URI */
    redirectUri: string;
    /** 로그인 URI */
    signInUri: string;
    /** 대시보드 로그인 URI (선택) */
    dashboardSignInUri?: string;
}

/**
 * LogtoM2MConfig
 *
 * M2M(Machine-to-Machine) 클라이언트 설정입니다.
 * Client Credentials 플로우에서 사용됩니다.
 */
export interface LogtoM2MConfig {
    /** Logto 인증 서버의 엔드포인트 URL */
    endpoint: string;
    /** M2M 애플리케이션의 Client ID */
    clientId: string;
    /** M2M 애플리케이션의 Client Secret */
    clientSecret: string;
    /** 접근할 리소스 서버 */
    resource: string;
    /** Logto Management API URL */
    apiUrl: string;
    /** 요청할 OAuth 스코프 목록 */
    scopes: string[];
}
