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

thoughtspot / mcp-server / 16061224324

03 Jul 2025 09:52PM UTC coverage: 88.438% (+0.7%) from 87.716%
16061224324

Pull #32

github

web-flow
Merge 00b1c638d into f2d580300
Pull Request #32: Handle cases where third party cookie is blocked by browsers

97 of 112 branches covered (86.61%)

Branch coverage included in aggregate %.

23 of 23 new or added lines in 2 files covered. (100.0%)

339 of 381 relevant lines covered (88.98%)

62.15 hits per line

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

100.0
/src/oauth-manager/token-utils.ts
1
export async function renderTokenCallback(instanceUrl: string, oauthReqInfo: string, assets: any, origin: string) {
2
    // Parse the oauthReqInfo if it's a string
3
    const parsedOAuthReqInfo = typeof oauthReqInfo === 'string' ? JSON.parse(oauthReqInfo) : oauthReqInfo;
391✔
4
    const oauthReqInfoJson = JSON.stringify(parsedOAuthReqInfo);
391✔
5

6
    try {
391✔
7
        // Read the HTML template
8
        const htmlResponse = await assets.fetch(`${origin}/oauth-callback.html`);
391✔
9
        if (!htmlResponse.ok) {
330✔
10
            throw new Error('Failed to load oauth-callback.html');
13✔
11
        }
12
        let htmlContent = await htmlResponse.text();
317✔
13

14
        // Read the CSS file
15
        const cssResponse = await assets.fetch(`${origin}/oauth-callback.css`);
317✔
16
        if (!cssResponse.ok) {
306✔
17
            throw new Error('Failed to load oauth-callback.css');
13✔
18
        }
19
        const css = await cssResponse.text();
293✔
20

21
        // Read the JS file
22
        const jsResponse = await assets.fetch(`${origin}/oauth-callback.js`);
293✔
23
        if (!jsResponse.ok) {
293✔
24
            throw new Error('Failed to load oauth-callback.js');
13✔
25
        }
26
        const js = await jsResponse.text();
280✔
27

28
        // Replace the template variable with the actual OAuth request info
29
        htmlContent = htmlContent.replace('{{OAUTH_REQ_INFO}}', oauthReqInfoJson);
280✔
30

31
        // Inline the CSS
32
        htmlContent = htmlContent.replace(
280✔
33
            '<link rel="stylesheet" href="oauth-callback.css">',
34
            `<style>${css}</style>`
35
        );
36

37
        // Inline the JS and add the instance URL as a global variable
38
        htmlContent = htmlContent.replace(
280✔
39
            '<script src="oauth-callback.js"></script>',
40
            `<script>window.INSTANCE_URL = '${instanceUrl}';</script>\n    <script>${js}</script>`
41
        );
42

43
        return htmlContent;
280✔
44
    } catch (error) {
45
        console.error('Error loading static files:', error);
111✔
46
        // Fallback to a simple error page if static files can't be loaded
47
        return `
111✔
48
        <!DOCTYPE html>
49
        <html>
50
        <head>
51
            <title>Error - ThoughtSpot Authorization</title>
52
            <style>
53
                body {
54
                    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
55
                    display: flex;
56
                    justify-content: center;
57
                    align-items: center;
58
                    height: 100vh;
59
                    margin: 0;
60
                    background-color: #f8f9fa;
61
                    color: #2c3e50;
62
                }
63
                .container {
64
                    text-align: center;
65
                    padding: 3rem;
66
                    background: white;
67
                    border-radius: 12px;
68
                    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
69
                    max-width: 480px;
70
                    width: 90%;
71
                }
72
                h2 {
73
                    color: #dc3545;
74
                    margin-bottom: 1rem;
75
                }
76
            </style>
77
        </head>
78
        <body>
79
            <div class="container">
80
                <h2>Authorization Error</h2>
81
                <p>Failed to load authorization page. Please try again or contact support.</p>
82
                <p>Error: ${error instanceof Error ? error.message : 'Unknown error'}</p>
111✔
83
            </div>
84
        </body>
85
        </html>
86
        `;
87
    }
88
}
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