CredentialManager¶
Main class for managing authentication and credentials.
Constructor¶
Options:
interface CredentialManagerOptions {
profileName?: string; // Specific profile to use
requireAuth?: boolean; // Throw error if not authenticated (default: false)
debug?: boolean; // Enable debug logging (default: false)
}
Example:
// Use default profile
const cm1 = new CredentialManager();
// Use specific profile
const cm2 = new CredentialManager({ profileName: 'production' });
// Require authentication
const cm3 = new CredentialManager({ requireAuth: true });
Methods¶
initialize(): Promise<void>¶
Initialize the credential manager and load credentials.
isAuthenticated(): boolean¶
Check if credentials are loaded and valid.
getApiUrl(): string | null¶
Get the configured API URL.
getTenant(): string | null¶
Extract tenant name from API URL.
getNamespace(): string | null¶
Get the default namespace.
getAuthHeaders(): Record<string, string>¶
Get authentication headers for API requests.
const headers = credentialManager.getAuthHeaders();
// Returns: { 'Authorization': 'APIToken your-token' }
// or: { 'X-Client-Cert': 'base64-encoded-cert', 'X-Client-Key': 'base64-encoded-key' }
getHttpsAgent(): https.Agent | null¶
Get configured HTTPS agent with TLS settings.
See Also¶
- Quick Start Guide - Get started with basic usage
- Authentication - Configure authentication methods
- HTTP Client Guide - Use the HTTP client