• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thoughtspot / mcp-server / 15125403956

19 May 2025 11:38PM UTC coverage: 12.262% (-0.1%) from 12.363%
15125403956

Pull #14

github

web-flow
Merge ab8f5de83 into 96f630b8b
Pull Request #14: Make base64 encoding url safe

5 of 101 branches covered (4.95%)

Branch coverage included in aggregate %.

0 of 6 new or added lines in 1 file covered. (0.0%)

40 of 266 relevant lines covered (15.04%)

0.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/oauth-manager/token-utils.ts
1
export function renderTokenCallback(instanceUrl: string, oauthReqInfo: string) {
2
    // Parse the oauthReqInfo if it's a string
3
    const parsedOAuthReqInfo = typeof oauthReqInfo === 'string' ? JSON.parse(oauthReqInfo) : oauthReqInfo;
×
4

5
    return `
×
6
    <!DOCTYPE html>
7
    <html>
8
    <head>
9
        <title>ThoughtSpot Authorization</title>
10
        <style>
11
            body {
12
                font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
13
                display: flex;
14
                justify-content: center;
15
                align-items: center;
16
                height: 100vh;
17
                margin: 0;
18
                background-color: #f8f9fa;
19
                color: #2c3e50;
20
            }
21
            .container {
22
                text-align: center;
23
                padding: 3rem;
24
                background: white;
25
                border-radius: 12px;
26
                box-shadow: 0 4px 6px rgba(0,0,0,0.1);
27
                max-width: 480px;
28
                width: 90%;
29
            }
30
            .logo {
31
                width: 48px;
32
                height: 48px;
33
                margin-bottom: 1.5rem;
34
            }
35
            h2 {
36
                font-size: 1.5rem;
37
                font-weight: 600;
38
                margin: 0 0 1rem 0;
39
                color: #1a1a1a;
40
            }
41
            .spinner {
42
                border: 3px solid #e9ecef;
43
                border-top: 3px solid #0066cc;
44
                border-radius: 50%;
45
                width: 36px;
46
                height: 36px;
47
                animation: spin 1s linear infinite;
48
                margin: 1.5rem auto;
49
            }
50
            @keyframes spin {
51
                0% { transform: rotate(0deg); }
52
                100% { transform: rotate(360deg); }
53
            }
54
            #status {
55
                font-size: 0.95rem;
56
                color: #495057;
57
                margin: 1rem 0;
58
                line-height: 1.5;
59
            }
60
            .footer {
61
                margin-top: 2rem;
62
                font-size: 0.85rem;
63
                color: #6c757d;
64
            }
65
        </style>
66
    </head>
67
    <body>
68
        <div class="container">
69
            <img src="https://avatars.githubusercontent.com/u/8906680?s=200&v=4" alt="ThoughtSpot Logo" class="logo">
70
            <h2>Authorization in Progress</h2>
71
            <div class="spinner"></div>
72
            <p id="status">Establishing secure connection...</p>
73
            <div class="footer">
74
                ThoughtSpot MCP Server
75
            </div>
76
        </div>
77
        <script>
78
            // Immediately invoke the async function
79
            (async function() {
80
                try {
81
                    const tokenUrl = new URL('callosum/v1/v2/auth/token/fetch?validity_time_in_sec=2592000', '${instanceUrl}');
82
                    console.log('Fetching token from:', tokenUrl.toString());
83
                    
84
                    document.getElementById('status').textContent = 'Retrieving authentication token...';
85
                    
86
                    const response = await fetch(tokenUrl.toString(), {
87
                        method: 'GET',
88
                        credentials: 'include'
89
                    });
90
                    
91
                    if (!response.ok) {
92
                        const errorText = await response.text();
93
                        throw new Error(\`Authentication failed (Status: \${response.status}): \${errorText}\`);
94
                    }
95
                    
96
                    const data = await response.json();
97
                    console.log('Token data:', data);
98
                    document.getElementById('status').textContent = 'Authentication successful. Securing your session...';
99

100
                    // Send the token to the server
101
                    const storeResponse = await fetch('/store-token', {
102
                        method: 'POST',
103
                        headers: {
104
                            'Content-Type': 'application/json'
105
                        },
106
                        body: JSON.stringify({ 
107
                            token: data,
108
                            oauthReqInfo: ${JSON.stringify(parsedOAuthReqInfo)},
109
                            instanceUrl: '${instanceUrl}'
110
                        })
111
                    });
112
                    const responseData = await storeResponse.json();
113

114
                    if (!storeResponse.ok) {
115
                        const errorText = await storeResponse.text();
116
                        throw new Error(\`Failed to store token (Status: \${storeResponse.status}): \${errorText}\`);
117
                    }
118

119
                    console.log('Redirecting to:', responseData.redirectTo);
120
                    window.location.href = responseData.redirectTo;
121
                    
122
                } catch (error) {
123
                    console.error('Error:', error);
124
                    document.getElementById('status').textContent = error.message;
125
                    document.getElementById('status').style.color = '#dc3545';
126
                    document.querySelector('h2').textContent = 'Authorization Failed';
127
                    document.querySelector('.spinner').style.display = 'none';
128
                }
129
            })();
130
        </script>
131
    </body>
132
    </html>
133
    `;
134
} 
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc