@agility/cli
Version:
Agility CLI for working with your content. (Public Beta)
79 lines (78 loc) • 3 kB
TypeScript
import { serverUser } from "../types/serverUser";
import * as mgmtApi from "@agility/management-sdk";
export declare class Auth {
private insecureMode;
constructor(insecureMode?: boolean);
setInsecureMode(insecure: boolean): void;
private createHttpsAgent;
private getFetchConfig;
private handleSSLError;
getEnv(): "dev" | "local" | "preprod" | "prod";
checkForEnvFile(): {
hasEnvFile: boolean;
guid?: string;
channel?: string;
locales?: string[];
};
getEnvKey(env: string): string;
logout(): Promise<void>;
generateCode(): Promise<string>;
determineBaseUrl(guid?: string, userBaseUrl?: string): string;
getBaseUrl(guid: string, userBaseUrl?: string): string;
getBaseUrlPoll(): string;
executeGet(apiPath: string, guid: string, userBaseUrl?: string): Promise<any>;
executePost(apiPath: string, guid: string, data: any): Promise<any>;
authorize(): Promise<string>;
/**
* Complete initialization: .env priming + validation + authentication + setup
* Handles everything needed to get the CLI ready for operation
*/
init(): Promise<boolean>;
/**
* Validate user access to an instance
*/
private validateInstanceAccess;
checkAuthorization(): Promise<boolean>;
login(): Promise<unknown>;
getToken(): Promise<string>;
cliPoll(data: FormData | URLSearchParams, guid?: string): Promise<any>;
getPreviewKey(guid: string, userBaseUrl?: string): Promise<any>;
getFetchKey(guid: string, userBaseUrl?: string): Promise<any>;
checkUserRole(guid: string): Promise<{
hasPermission: boolean;
role: string;
}>;
getUser(guid?: string): Promise<serverUser>;
getUsers(guid: string, userBaseUrl?: string): Promise<serverUser[]>;
/**
* Determine if permission checks should be skipped based on state flags
*/
/**
* Validate command-specific requirements and set up instance access
* This should be called by each command after auth.init()
*/
validateCommand(commandType: "pull" | "sync" | "clean" | "interactive" | "push"): Promise<boolean>;
shouldSkipPermissionCheck(): boolean;
/**
* Validate and resolve command parameters from args and .env file
* Centralizes all GUID, LOCALE, CHANNEL validation logic
*
* @param args - Command arguments object
* @param requiredFields - Array of required field names
* @returns Validated parameters object
*/
validateAndResolveParams(args: any, requiredFields?: string[]): {
sourceGuid: string;
targetGuid: string;
locale: string;
channel: string;
};
/**
* Setup authentication for pull operations
* Handles single instance authentication and API key retrieval
*/
setupPullAuthentication(guid: string, isPreview: boolean, userBaseUrl?: string): Promise<{
mgmtApiOptions: mgmtApi.Options;
apiKeyForPull: string;
}>;
}