adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
121 lines (120 loc) • 3.79 kB
TypeScript
/**
* Authentication helpers for OpenAPI tools
*/
import { AuthSchemeType } from './AuthTypes';
import { AuthCredential } from '../../../auth/AuthCredential';
import { ApiParameter } from '../common/common';
export declare enum APIKeyIn {
header = "header",
query = "query",
cookie = "cookie"
}
export declare class APIKey {
type_: AuthSchemeType;
in_: APIKeyIn;
name: string;
constructor(config: {
type_: AuthSchemeType;
in_: APIKeyIn;
name: string;
});
}
export declare class HTTPBase {
type_: AuthSchemeType;
scheme: string;
constructor(config: {
type_: AuthSchemeType;
scheme: string;
});
}
export declare class HTTPBearer extends HTTPBase {
bearerFormat?: string;
constructor(config: {
type_: AuthSchemeType;
scheme: string;
bearerFormat?: string;
});
}
export declare class OAuth2 {
type_: AuthSchemeType;
flows: Record<string, any>;
constructor(config: {
type_: AuthSchemeType;
flows: Record<string, any>;
});
}
export declare class OpenIdConnect {
type_: AuthSchemeType;
openIdConnectUrl: string;
constructor(config: {
type_: AuthSchemeType;
openIdConnectUrl: string;
});
}
export declare class OpenIdConnectWithConfig extends OpenIdConnect {
authorization_endpoint: string;
token_endpoint: string;
scopes: string[];
constructor(config: {
type_: AuthSchemeType;
openIdConnectUrl: string;
authorization_endpoint: string;
token_endpoint: string;
scopes: string[];
});
}
export interface HttpCredentials {
token?: string;
username?: string;
password?: string;
}
export interface HttpAuth {
scheme: string;
credentials: HttpCredentials;
}
export interface ServiceAccountCredential {
type: string;
project_id: string;
private_key_id: string;
private_key: string;
client_email: string;
client_id: string;
auth_uri: string;
token_uri: string;
auth_provider_x509_cert_url: string;
client_x509_cert_url: string;
universe_domain: string;
}
export interface ServiceAccount {
service_account_credential: ServiceAccountCredential;
scopes: string[];
}
export declare const INTERNAL_AUTH_PREFIX = "__auth_";
/**
* Convert a token to a scheme and credential
*/
export declare function tokenToSchemeCredential(tokenType: string, location: string, name: string, token?: string): [any, AuthCredential | null];
/**
* Convert a service account config dict to a scheme and credential
*/
export declare function serviceAccountDictToSchemeCredential(config: Record<string, any>, scopes: string[]): [HTTPBearer, AuthCredential];
/**
* Convert a ServiceAccount to a scheme and credential
*/
export declare function serviceAccountSchemeCredential(config: ServiceAccount): [HTTPBearer, AuthCredential];
/**
* Convert an OpenID Connect config dict to a scheme and credential
*/
export declare function openidDictToSchemeCredential(configDict: Record<string, any>, scopes: string[], credentialDict: Record<string, any>): [OpenIdConnectWithConfig, AuthCredential];
/**
* Fetch OpenID Connect configuration from a URL and convert to a scheme and credential
*/
export declare function openidUrlToSchemeCredential(openidUrl: string, scopes: string[], credentialDict: Record<string, any>): Promise<[OpenIdConnectWithConfig, AuthCredential]>;
/**
* Convert an auth credential to a parameter and keyword args
*/
export declare function credentialToParam(authScheme: any, authCredential: AuthCredential | null): [ApiParameter | null, Record<string, any> | null];
/**
* Convert a dictionary to an auth scheme
*/
export declare function dictToAuthScheme(data: Record<string, any>): any;