UNPKG

@dataroadinc/setup-auth

Version:

CLI tool and programmatic API for automated OAuth setup across cloud platforms

47 lines (46 loc) 2.09 kB
import { AuthClient, GoogleAuth as AuthLibGoogleAuth, GoogleAuthOptions } from "google-auth-library"; import { GoogleAuth as GaxGoogleAuth } from "google-gax"; export type GcpAuthClient = { getAccessToken(): Promise<{ token: string | null | undefined; }>; projectId?: string; quotaProjectId?: string; }; export declare abstract class GcpAuthenticatedIdentity { protected authLibGoogleAuth: AuthLibGoogleAuth<AuthClient>; protected gaxGoogleAuth: GaxGoogleAuth; protected options: GoogleAuthOptions; constructor(options: GoogleAuthOptions); getAccessToken(): Promise<string>; abstract getCurrentUserEmail(): Promise<string>; getAuthClient(): Promise<AuthLibGoogleAuth<AuthClient>>; getGaxAuthClient(): Promise<GaxGoogleAuth>; getAuthClientForResourceManager(): Promise<AuthLibGoogleAuth<AuthClient>>; getAuthClientForIAM(): Promise<AuthLibGoogleAuth<AuthClient>>; getAuthClientForOAuth2(): Promise<AuthLibGoogleAuth<AuthClient>>; } export declare class GcpUserAccountIdentity extends GcpAuthenticatedIdentity { constructor(); getCurrentUserEmail(): Promise<string>; } export declare class GcpAdcIdentity extends GcpAuthenticatedIdentity { constructor(); getCurrentUserEmail(): Promise<string>; } export declare class GcpServiceAccountIdentity extends GcpAuthenticatedIdentity { constructor(keyFilePath: string); getCurrentUserEmail(): Promise<string>; } export type AuthenticationType = "Service Account" | "ADC" | "User Account"; export type AuthenticationContext = { forceAuthType?: AuthenticationType; serviceAccountPath?: string; }; export declare function detectAuthenticationType(context?: AuthenticationContext): AuthenticationType; export declare class GcpIdentityFactory { static createIdentity(context?: AuthenticationContext): GcpAuthenticatedIdentity; static createAdcIdentity(): GcpAuthenticatedIdentity; static createUserIdentity(): GcpAuthenticatedIdentity; static createServiceAccountIdentity(keyFilePath: string | undefined): GcpAuthenticatedIdentity; }