@capgo/cli
Version:
A CLI to upload to capgo servers
48 lines (47 loc) • 2.19 kB
TypeScript
/**
* Security Policy Error Handling for CLI, SDK, and MCP
*
* This module provides utilities for parsing and displaying security policy errors
* returned from the Capgo API. It transforms error codes into human-readable messages.
*
* Note: These are the error codes actually returned by the backend API.
* Other security policies (2FA, password policy, hashed API keys) are enforced
* via RLS which returns generic permission denied errors.
*/
export declare const SECURITY_POLICY_ERRORS: {
readonly ORG_REQUIRES_EXPIRING_KEY: "org_requires_expiring_key";
readonly EXPIRATION_REQUIRED: "expiration_required";
readonly EXPIRATION_EXCEEDS_MAX: "expiration_exceeds_max";
};
export type SecurityPolicyErrorCode = typeof SECURITY_POLICY_ERRORS[keyof typeof SECURITY_POLICY_ERRORS];
export declare const SECURITY_POLICY_MESSAGES: Record<string, string>;
export type { ParsedSecurityError } from '../schemas/common';
type ParsedSecurityError = import('../schemas/common').ParsedSecurityError;
/**
* Check if an error code is a security policy error.
*/
export declare function isSecurityPolicyError(errorCode: string): boolean;
/**
* Parse an error response and return formatted security policy information.
*
* @param error - The error object or error message from the API
* @returns ParsedSecurityError with formatted message and metadata
*/
export declare function parseSecurityPolicyError(error: unknown): ParsedSecurityError;
/**
* Get a human-readable message for a security policy error code.
* Returns the original message if not a security policy error.
*
* @param errorCode - The error code from the API
* @param defaultMessage - The default message to use if not a security policy error
* @returns Human-readable error message
*/
export declare function getSecurityPolicyMessage(errorCode: string, defaultMessage?: string): string;
/**
* Format an API error for CLI display with security policy awareness.
* This should be used when displaying errors to users in the CLI.
*
* @param error - The error object from the API
* @returns Formatted error string for CLI display
*/
export declare function formatApiErrorForCli(error: unknown): string;