Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
89 lines (89 loc) · 4.39 KB
/
Copy pathindex.html
File metadata and controls
89 lines (89 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Connecting GitHub...</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #0d1117; color: #c9d1d9; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; text-align: center; }
.container { max-width: 420px; padding: 2rem; }
.spinner { border: 4px solid #21262d; border-top: 4px solid #58a6ff; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
h1 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.5rem; }
p { font-size: 0.9rem; color: #8b949e; }
.error { color: #f85149; }
.success { color: #3fb950; }
.btn { display: inline-block; background: #238636; color: #fff; text-decoration: none; padding: 0.8rem 1.6rem; border-radius: 8px; font-weight: 600; margin-top: 1rem; }
.btn:hover { background: #2ea043; }
</style>
</head>
<body>
<div class="container">
<div id="spinner" class="spinner"></div>
<h1 id="title">Connecting your GitHub account...</h1>
<p id="message">Please wait while we process your authorization.</p>
<div id="fallback" style="display:none;">
<a class="btn" id="fallbackLink" href="https://t.me/github_client_tgbot">Open Telegram Bot</a>
<p style="margin-top:1rem;font-size:0.8rem">If not redirected automatically, tap the button and send /profile</p>
</div>
</div>
<script>
(function () {
var params = new URLSearchParams(window.location.search);
var code = params.get('code');
var state = params.get('state');
var spinner = document.getElementById('spinner');
var title = document.getElementById('title');
var message = document.getElementById('message');
var fallback = document.getElementById('fallback');
var fallbackLink = document.getElementById('fallbackLink');
var deepLink = 'https://t.me/github_client_tgbot';
function showError(t, m) {
spinner.style.display = 'none';
title.textContent = t;
title.className = 'error';
message.textContent = m;
fallback.style.display = 'block';
}
function showSuccess() {
spinner.style.display = 'none';
title.textContent = 'Connected!';
title.className = 'success';
message.textContent = 'Your GitHub is linked. Redirecting to Telegram...';
fallback.style.display = 'block';
fallbackLink.href = deepLink;
setTimeout(function(){ window.location.href = deepLink; }, 1200);
}
if (!code || !state) {
showError('Authorization failed', 'Missing code or state. Please run /connect again from Telegram.');
return;
}
// URLSearchParams.get() already URL-decodes state -> this IS the webhook URL
var webhookUrl = state;
if (webhookUrl.indexOf('http') !== 0) {
try { webhookUrl = decodeURIComponent(state); } catch(e) {}
}
if (webhookUrl.indexOf('http') !== 0) {
showError('Invalid state', 'State is not a valid webhook. Please run /connect again.');
return;
}
fetch(webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'oauth_code=' + encodeURIComponent(code)
})
.then(function (res) {
if (!res.ok) throw new Error('Webhook ' + res.status);
return res.text();
})
.then(function () { showSuccess(); })
.catch(function (err) {
console.error(err);
// TBC webhooks often succeed server-side even when CORS blocks the response
// Treat as success and redirect — bot will send confirmation in Telegram
showSuccess();
});
})();
</script>
</body>
</html>