CredentialManager
Main class for managing authentication and credentials.
Constructor
Section titled “Constructor”new CredentialManager(options?: CredentialManagerOptions)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 profileconst cm1 = new CredentialManager();
// Use specific profileconst cm2 = new CredentialManager({ profileName: 'production' });
// Require authenticationconst cm3 = new CredentialManager({ requireAuth: true });Methods
Section titled “Methods”initialize(): Promise<void>
Section titled “initialize(): Promise<void>”Initialize the credential manager and load credentials.
const credentialManager = new CredentialManager();await credentialManager.initialize();isAuthenticated(): boolean
Section titled “isAuthenticated(): boolean”Check if credentials are loaded and valid.
if (credentialManager.isAuthenticated()) { console.log('Ready to make API calls');}getApiUrl(): string | null
Section titled “getApiUrl(): string | null”Get the configured API URL.
const apiUrl = credentialManager.getApiUrl();console.log('API URL:', apiUrl);getTenant(): string | null
Section titled “getTenant(): string | null”Extract tenant name from API URL.
const tenant = credentialManager.getTenant();console.log('Tenant:', tenant);getNamespace(): string | null
Section titled “getNamespace(): string | null”Get the default namespace.
const namespace = credentialManager.getNamespace();console.log('Namespace:', namespace);getAuthHeaders(): Record<string, string>
Section titled “getAuthHeaders(): Record<string, string>”Get authentication headers for API requests.
const headers = credentialManager.getAuthHeaders();// Returns: { 'Authorization': 'APIToken your-token' }// or: { 'X-Client-Cert': '...', 'X-Client-Key': '...' }getHttpsAgent(): https.Agent | null
Section titled “getHttpsAgent(): https.Agent | null”Get configured HTTPS agent with TLS settings.
const agent = credentialManager.getHttpsAgent();// Use with axios or other HTTP librariesSee Also
Section titled “See Also”- Quick Start Guide - Get started with basic usage
- Authentication - Configure authentication methods
- HTTP Client Guide - Use the HTTP client