#!/usr/bin/env node
/**
* Test the exact authentication that works in stdio mode
*/
const path = require('path');
// Use the exact same imports as the working stdio server
const { UmbrellaDualAuth } = require('../../dist/dual-auth.js');
async function testAuth() {
console.log('🔐 Testing exact authentication as used in stdio mode');
console.log('='.repeat(60));
// Use the same baseURL as UserSessionManager uses
const baseURL = 'https://api.umbrellacost.io/api/v1';
const dualAuth = new UmbrellaDualAuth(baseURL);
const credentials = {
username: 'david+saola@umbrellacost.com',
password: 'Dsamsung1!'
};
console.log('Username:', credentials.username);
console.log('Password:', '*'.repeat(credentials.password.length));
console.log('Base URL:', baseURL);
console.log('');
try {
console.log('Attempting authentication...');
const authResult = await dualAuth.authenticate(credentials);
console.log('\n✅ Authentication Successful!');
console.log('Auth Result:', JSON.stringify(authResult, null, 2));
const authHeaders = dualAuth.getAuthHeaders();
console.log('\nAuth Headers:', JSON.stringify(authHeaders, null, 2));
return authResult;
} catch (error) {
console.error('\n❌ Authentication Failed');
console.error('Error:', error.message);
if (error.response) {
console.error('Status:', error.response.status);
console.error('Data:', JSON.stringify(error.response.data, null, 2));
}
throw error;
}
}
async function main() {
try {
await testAuth();
console.log('\n✅ Test completed successfully!');
} catch (error) {
console.error('\n❌ Test failed:', error.message);
process.exit(1);
}
}
main();