import { CopilotUserQuotaInfo } from '../../chat/common/chatQuotaService';
/**
 * A function used to determine if the org list contains an internal organization
 * @param orgList The list of organizations the user is a member of
 * Whether or not it contains an internal org
 */
export declare function containsInternalOrg(orgList: string[]): boolean;
/**
 * A function used to determine if the org list contains a VS Code organization
 * @param orgList The list of organizations the user is a member of
 * Whether or not it contains a VS Code org
 */
export declare function containsVSCodeOrg(orgList: string[]): boolean;
export declare class CopilotToken {
    private readonly _info;
    private readonly tokenMap;
    constructor(_info: ExtendedTokenInfo);
    private parseToken;
    get token(): string;
    get sku(): CopilotSku | undefined;
    /**
     * Evaluates `has_cfi_access?` which is defined as `!has_cfb_access? && !has_cfe_access?`
     * (cfb = copilot for business, cfe = copilot for enterprise).
     * So it's also true for copilot free users.
     */
    get isIndividual(): boolean;
    get organizationList(): string[];
    /**
     * Returns the list of organization logins that provide Copilot access to the user.
     * These are the organizations through which the user has a Copilot subscription (Business/Enterprise).
     */
    get organizationLoginList(): string[];
    get enterpriseList(): number[];
    get endpoints(): Endpoints | undefined;
    get isInternal(): boolean;
    get isMicrosoftInternal(): boolean;
    get isGitHubInternal(): boolean;
    get isFreeUser(): boolean;
    get isNoAuthUser(): boolean;
    get isManagedPlan(): boolean;
    get isUsageBasedBilling(): boolean;
    get isChatQuotaExceeded(): boolean;
    get isCompletionsQuotaExceeded(): boolean;
    get codeQuoteEnabled(): boolean;
    get isVscodeTeamMember(): boolean;
    get codexAgentEnabled(): boolean;
    get copilotPlan(): 'free' | 'individual' | 'individual_pro' | 'individual_max' | 'business' | 'enterprise';
    /**
     * Returns the raw copilot_plan string from the token payload without normalization.
     * Used when the exact plan value must be preserved (e.g. for per-SKU routing overrides
     * where individual_edu, individual_pro_plus, etc. need distinct handling).
     */
    get rawCopilotPlan(): string;
    get quotaInfo(): {
        quota_snapshots: {
            chat: {
                quota_id: string;
                entitlement: number;
                remaining: number;
                unlimited: boolean;
                overage_count: number;
                overage_permitted: boolean;
                percent_remaining: number;
                has_quota?: boolean;
            };
            completions: {
                quota_id: string;
                entitlement: number;
                remaining: number;
                unlimited: boolean;
                overage_count: number;
                overage_permitted: boolean;
                percent_remaining: number;
                has_quota?: boolean;
            };
            premium_interactions: {
                quota_id: string;
                entitlement: number;
                remaining: number;
                unlimited: boolean;
                overage_count: number;
                overage_permitted: boolean;
                percent_remaining: number;
                has_quota?: boolean;
            };
        } | undefined;
        quota_reset_date: string | undefined;
    };
    get tokenBasedBilling(): boolean | undefined;
    get username(): string;
    private _isTelemetryEnabled;
    isTelemetryEnabled(): boolean;
    private _isPublicSuggestionsEnabled;
    isPublicSuggestionsEnabled(): boolean;
    isCopilotIgnoreEnabled(): boolean;
    get isCopilotCodeReviewEnabled(): boolean;
    isEditorPreviewFeaturesEnabled(): boolean;
    isBlackbirdExternalIndexingEnabled(): boolean;
    isMcpEnabled(): boolean;
    isClientBYOKEnabled(): boolean;
    getTokenValue(key: string): string | undefined;
    isExpandedClientSideIndexingEnabled(): boolean;
    isFcv1(): boolean;
    /**
     * Is snippy in blocking mode
     */
    isSn(): boolean;
}
/**
 * Details of the user's telemetry consent status we get from the server during token retrieval.
 *
 * `unconfigured` is a transitional state for pre-GA that indicates the user is in the Technical Preview
 * and needs to be asked about telemetry consent client-side. It can be removed post-GA as the server
 * will never return it again.
 *
 * `enabled` indicates that they agreed to full telemetry.
 *
 * `disabled` indicates that they opted out of full telemetry so we can only send the core messages
 * that users cannot opt-out of.
 *
 */
export type UserTelemetryChoice = 'enabled' | 'disabled';
/**
 * A notification we get from the server during token retrieval. Needs to be presented to the user.
 * Used for both success notifications (user_notification) and error notifications (error_details).
 */
export interface NotificationEnvelope {
    message: string;
    notification_id: TokenErrorNotificationId | string;
    title: string;
    url: string;
}
/**
 * Well-known SKU values that are checked in source code.
 * The actual SKU can be any string - these are just the ones we explicitly handle.
 */
export type WellKnownSku = 'free_limited_copilot' | 'no_auth_limited_copilot';
/**
 * User's access type/SKU from the Copilot token endpoint.
 * This is a string that can be any SKU value - use WellKnownSku for type-safe comparisons.
 */
export type CopilotSku = WellKnownSku | string;
export interface Endpoints {
    api?: string;
    'origin-tracker'?: string;
    proxy?: string;
    telemetry?: string;
}
/**
 * A server response containing a Copilot token and metadata associated with it.
 * This is the success response (HTTP 200) from the /copilot_internal/v2/token endpoint.
 */
export interface TokenEnvelope {
    /** HMAC-signed token for Copilot proxy authentication. v2 format: fields:mac where fields are ';' separated key=value pairs. */
    token: string;
    /** Unix timestamp (seconds) when token expires. */
    expires_at: number;
    /** Seconds until client should request a new token. */
    refresh_in: number;
    /** User's access type/SKU. */
    sku: CopilotSku;
    /** Whether user has Copilot Individual access. */
    individual: boolean;
    /** Whether client-side indexing for Blackbird is enabled. */
    blackbird_clientside_indexing: boolean;
    /** Whether code quote/citation is enabled. */
    code_quote_enabled: boolean;
    /** Whether Copilot code review is enabled. */
    code_review_enabled: boolean;
    /** Whether code search is enabled. */
    codesearch: boolean;
    /** Whether content exclusion (.copilotignore) is enabled. */
    copilotignore_enabled: boolean;
    /** 'enabled', 'disabled', or 'unconfigured' for public code suggestions. */
    public_suggestions: 'enabled' | 'disabled' | 'unconfigured';
    /** 'enabled' or 'disabled' for telemetry. */
    telemetry: 'enabled' | 'disabled';
    /** SKU-isolated endpoints. */
    endpoints?: Endpoints;
    /** Enterprise IDs if user has enterprise access. */
    enterprise_list?: number[] | null;
    /** Quota remaining for free/limited users. Null for non-free users. */
    limited_user_quotas?: {
        chat: number;
        completions: number;
    } | null;
    /** Unix timestamp when quotas reset for free/limited users. Null for non-free users. */
    limited_user_reset_date?: number | null;
    /** Organization tracking IDs if user has org access. */
    organization_list?: string[];
}
/**
 * The shape of an error response (HTTP 403) from the server when token retrieval fails.
 */
export interface ErrorEnvelope {
    /** Whether user can sign up for Copilot Free. Null when not applicable. */
    can_signup_for_limited?: boolean | null;
    /** Detailed error information including notification_id. */
    error_details: NotificationEnvelope;
    /** Generic error message with TOS text. */
    message: string;
    /** Optional reason string. */
    reason?: string;
}
/**
 * The shape of a standard error response from the server. Used for generic errors like rate limiting.
 */
export interface StandardErrorEnvelope {
    message: string;
    documentation_url: string;
    status: string;
}
/**
 * Result of validating a token envelope with the two-tier validation strategy.
 */
export type TokenValidationResult = {
    valid: true;
    strategy: 'strict';
    envelope: TokenEnvelope;
} | {
    valid: true;
    strategy: 'fallback';
    strictError: string;
    envelope: TokenEnvelope;
    fallbackError?: string;
} | {
    valid: false;
    strategy: 'failed';
    strictError: string;
    fallbackError: string;
};
/**
 * Validates a token envelope using a two-tier strategy:
 * 1. First tries strict validation against the full schema.
 * 2. If that fails, falls back to validating only critical fields (token, expires_at, refresh_in).
 *
 * This allows the client to continue working even if the server changes non-critical fields,
 * while providing telemetry data to track schema drift.
 */
export declare function validateTokenEnvelope(obj: unknown): TokenValidationResult;
export declare function isTokenEnvelope(obj: unknown): obj is TokenEnvelope;
export declare function isErrorEnvelope(obj: unknown): obj is ErrorEnvelope;
export declare function isStandardErrorEnvelope(obj: unknown): obj is StandardErrorEnvelope;
/**
 * Combined response type from the /copilot_internal/v2/token endpoint.
 * Can be either a success (TokenEnvelope) or error (ErrorEnvelope) response.
 */
export type CopilotTokenResponse = TokenEnvelope | ErrorEnvelope | StandardErrorEnvelope;
/**
 * A server response containing the user info for the copilot user from the /copilot_internal/user endpoint
 */
export interface CopilotUserInfo extends CopilotUserQuotaInfo {
    access_type_sku: string;
    analytics_tracking_id: string;
    assigned_date: string;
    can_signup_for_limited: boolean;
    copilot_plan: string;
    organization_login_list: string[];
    organization_list: Array<{
        login: string;
        name: string | null;
    }>;
    codex_agent_enabled?: boolean;
    token_based_billing?: boolean;
}
/**
 * The token envelope extended with additional metadata that is helpful to have.
 * This includes information from both the token endpoint and the user info endpoint.
 */
export type ExtendedTokenInfo = TokenEnvelope & {
    username: string;
    isVscodeTeamMember: boolean;
} & Pick<CopilotUserInfo, 'copilot_plan' | 'quota_snapshots' | 'quota_reset_date' | 'codex_agent_enabled' | 'organization_login_list' | 'token_based_billing'>;
/**
 * Creates a minimal ExtendedTokenInfo for testing purposes.
 * All required TokenEnvelope fields are populated with sensible defaults.
 */
export declare function createTestExtendedTokenInfo(overrides?: Partial<ExtendedTokenInfo>): ExtendedTokenInfo;
/**
 * Reasons for token retrieval failures.
 */
export type TokenErrorReason = 
/** User doesn't have Copilot access or authorization failed. Includes detailed error_details from server with notification_id specifying the specific authorization issue. */
'NotAuthorized' | 
/** Network request failed - no response received from the server (connection failed, endpoint unreachable, etc.). */
'RequestFailed' | 
/** Server response could not be parsed as JSON (malformed or unexpected response format). */
'ParseFailed' | 
/** User not authenticated with GitHub through VS Code. Only returned from VS Code integration layer, not from platform token minting. */
'GitHubLoginFailed' | 
/** Server returned 401 Unauthorized HTTP status. */
'HTTP401' | 
/** GitHub API rate limit exceeded (403 status with rate limit message). */
'RateLimited';
export declare const enum TokenErrorNotificationId {
    NoCopilotAccess = "no_copilot_access",
    NotSignedUp = "not_signed_up",
    SubscriptionEnded = "subscription_ended",
    EnterPriseManagedUserAccount = "enterprise_managed_user_account",
    FeatureFlagBlocked = "feature_flag_blocked",
    SpammyUser = "spammy_user",
    BillingLocked = "billing_locked",
    TradeRestricted = "trade_restricted",
    TradeRestrictedCountry = "trade_restricted_country",
    CodespacesDemoInactive = "codespaces_demo_inactive",
    SnippyNotConfigured = "snippy_not_configured",
    ExpiredCoupon = "expired_coupon",
    RevokedCoupon = "revoked_coupon",
    GoHttpClient = "go_http_client",
    ProgrammaticTokenGeneration = "programmatic_token_generation",
    AccessRevoked = "access_revoked",
    ServerError = "server_error"
}
/**
 * Notification IDs that appear in user_notification on success responses.
 */
export type SuccessNotificationId = 'subscription_trial_ending' | 'subscription_trial_ended' | 'subscription_ending' | 'free_over_limits' | 'codespaces_demo_welcome' | `copilot_seat_added_${number}`;
export type TokenError = {
    reason: TokenErrorReason;
    notification_id?: TokenErrorNotificationId | string;
    message?: string;
    /** URL for action button to help user resolve the error. */
    url?: string;
    /** Title for the action button. */
    title?: string;
};
export type TokenInfoOrError = ({
    kind: 'success';
} & ExtendedTokenInfo) | ({
    kind: 'failure';
} & TokenError);
//# sourceMappingURL=copilotToken.d.ts.map