export interface GleanConfigTokenAccess { authType: 'token'; token: string; actAs?: string; } export interface GleanConfigOAuthAccess { authType: 'oauth'; issuer: string; clientId: string; /** * Client secret for the device flow OAuth client. * * Note this is not actually a secret and does not secure anything. It * should be thought of as an extension of the client identifier. * * It's not recommended to even use client secrets for public OAuth clients, * but some providers require its use even for clients that cannot keep * secrets. */ clientSecret?: string; authorizationEndpoint: string; tokenEndpoint: string; } /** * Config where the user has only specified the baseUrl. In order to * authenticate we'd have to upgrade to a GleanOAuthConfig by querying the * resource's metadata. */ export interface GleanBasicConfigNoToken { authType: 'unknown'; issuer?: string; clientId?: string; /** * Client secret for the device flow OAuth client. * * Note this is not actually a secret and does not secure anything. It * should be thought of as an extension of the client identifier. * * It's not recommended to even use client secrets for public OAuth clients, * but some providers require its use even for clients that cannot keep * secrets. */ clientSecret?: string; authorizationEndpoint?: string; tokenEndpoint?: string; } interface GleanCommonConfig { baseUrl: string; } export type GleanTokenConfig = GleanCommonConfig & GleanConfigTokenAccess; export type GleanOAuthConfig = GleanCommonConfig & GleanConfigOAuthAccess; export type GleanBasicConfig = GleanCommonConfig & GleanBasicConfigNoToken; /** * Configuration interface for Glean client initialization. */ export type GleanConfig = GleanBasicConfig | GleanTokenConfig | GleanOAuthConfig; /** * Type guard to check if a GleanConfig uses token authentication */ export declare function isGleanTokenConfig(config: GleanConfig): config is GleanConfig & GleanConfigTokenAccess; /** * Type guard to check if a GleanConfig uses OAuth authentication */ export declare function isOAuthConfig(config: GleanConfig): config is GleanConfig & GleanConfigOAuthAccess; /** * Type guard to check if a GleanConfig uses OAuth authentication */ export declare function isBasicConfig(config: GleanConfig): config is GleanConfig & GleanBasicConfig; /** * Type that represents the return value of getConfig based on the discoverOAuth option. * When discoverOAuth is true, the return type cannot be GleanBasicConfig. */ type GetConfigReturn = T['discoverOAuth'] extends true ? GleanTokenConfig | GleanOAuthConfig : GleanConfig; interface GetConfigOptions { discoverOAuth?: boolean; } /** * Validates required environment variables and returns client configuration. * * @param opts - Configuration options * @param opts.discoverOAuth - If true, attempts to discover OAuth * configuration via network calls to load oauth protected resource metadata. * Guarantees the return type is not a GleanBasicConfig * @returns A promise that resolves to: * - GleanTokenConfig | GleanOAuthConfig if discoverOAuth is true * - GleanConfig (which may include GleanBasicConfig) if discoverOAuth is false * @throws {Error} If required environment variables are missing */ export declare function getConfig(opts?: T): Promise>; type SafeConfig = Partial, unknown>>; export declare function sanitizeConfig(config: GleanConfig): SafeConfig; export {}; //# sourceMappingURL=config.d.ts.map