adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
109 lines (108 loc) • 3.34 kB
TypeScript
/**
* Enum for supported authentication scheme types.
*/
export declare enum AuthSchemeType {
API_KEY = "apiKey",
HTTP = "http",
OAUTH2 = "oauth2",
OPEN_ID_CONNECT = "openIdConnect",
SERVICE_ACCOUNT = "serviceAccount"
}
/**
* Enum for OAuth2 grant types.
*/
export declare enum OAuthGrantType {
CLIENT_CREDENTIALS = "client_credentials",
AUTHORIZATION_CODE = "authorization_code",
IMPLICIT = "implicit",
PASSWORD = "password",
REFRESH_TOKEN = "refresh_token"
}
/**
* Interface for OpenIdConnectWithConfig, matching the Python class.
*/
export interface OpenIdConnectWithConfig {
type?: AuthSchemeType;
authorization_endpoint: string;
token_endpoint: string;
userinfo_endpoint?: string;
revocation_endpoint?: string;
token_endpoint_auth_methods_supported?: string[];
grant_types_supported?: string[];
scopes?: string[];
[key: string]: any;
}
/**
* SecuritySchemeConfig is a union of SecurityScheme and OpenIdConnectWithConfig.
* In TypeScript, SecurityScheme can be any object with a 'type' property.
*/
export type SecuritySchemeConfig = {
type: AuthSchemeType;
[key: string]: any;
} | OpenIdConnectWithConfig;
/**
* Utility function to get OAuthGrantType from an OAuthFlows-like object.
*/
export declare function getOAuthGrantTypeFromFlow(flow: any): OAuthGrantType | undefined;
/**
* Base interface for authentication schemes
*/
export interface AuthScheme {
/**
* The type of authentication scheme
*/
type: string;
/**
* Generate authentication headers for HTTP requests
* @param credentials The credentials to use for authentication
* @returns The headers to include in HTTP requests
*/
generateHeaders: (credentials: any) => Record<string, string>;
}
/**
* API key authentication scheme
*/
export declare class ApiKeyAuthScheme implements AuthScheme {
type: string;
private headerName;
/**
* Initializes the API key authentication scheme
* @param headerName The name of the header to include the API key in
*/
constructor(headerName?: string);
/**
* Generate authentication headers for HTTP requests
* @param apiKey The API key to include in the headers
* @returns The headers to include in HTTP requests
*/
generateHeaders(apiKey: string): Record<string, string>;
}
/**
* Bearer token authentication scheme
*/
export declare class BearerAuthScheme implements AuthScheme {
type: string;
/**
* Generate authentication headers for HTTP requests
* @param token The bearer token to include in the headers
* @returns The headers to include in HTTP requests
*/
generateHeaders(token: string): Record<string, string>;
}
/**
* Basic authentication scheme
*/
export declare class BasicAuthScheme implements AuthScheme {
type: string;
/**
* Generate authentication headers for HTTP requests
* @param credentials The credentials to use for authentication
* @param credentials.username The username for basic authentication
* @param credentials.password The password for basic authentication
* @returns The headers to include in HTTP requests
*/
generateHeaders(credentials: {
username: string;
password: string;
}): Record<string, string>;
}