const https = require('https');
// Test configuration
const MCP_ENDPOINT = 'https://opposition-mailing-damaged-chronic.trycloudflare.com/mcp';
async function makeRequest(body) {
return new Promise((resolve, reject) => {
const url = new URL(MCP_ENDPOINT);
const options = {
hostname: url.hostname,
port: url.port || 443,
path: url.pathname,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json, text/event-stream'
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => data += chunk);
res.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (e) {
resolve(data);
}
});
});
req.on('error', reject);
req.write(JSON.stringify(body));
req.end();
});
}
async function testLogin() {
console.log('🔍 Testing Login and Customer Detection Override\n');
// Step 1: Get OAuth authorization endpoint
console.log('Step 1: Getting OAuth authorization server info...');
const authServerRequest = {
jsonrpc: '2.0',
method: 'tools/call',
params: {
name: 'test'
},
id: 1
};
const authServerResponse = await makeRequest(authServerRequest);
console.log('Auth server response:', JSON.stringify(authServerResponse, null, 2));
if (authServerResponse.error && authServerResponse.error.data) {
const authData = authServerResponse.error.data;
console.log('\n🔗 OAuth URLs:');
console.log('Authorization URL:', authData.authorization_url);
console.log('Token Endpoint:', authData.token_endpoint);
console.log('\n📝 To test this:');
console.log('1. Open the authorization URL in a browser');
console.log('2. Login with your credentials');
console.log('3. Extract the authorization token from the network logs');
console.log('4. Run this script again with AUTH_TOKEN environment variable');
}
}
// Run the test
testLogin().catch(console.error);