-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathgithub-token-validator-glassmorphism.html
More file actions
296 lines (296 loc) · 11 KB
/
Copy pathgithub-token-validator-glassmorphism.html
File metadata and controls
296 lines (296 loc) · 11 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!doctype html>
<html lang="en">
<head>
<!-- ========================= META INFORMATION ========================== -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Validate GitHub Personal Access Tokens and view owner, scopes, expiry date, and status." />
<title>GitHub Token Validator | Glassmorphism</title>
<style>
/* ========================= CSS VARIABLES ========================== */
:root {
--background-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--glass-background: rgba(255, 255, 255, 0.15);
--glass-border: rgba(255, 255, 255, 0.25);
--text-primary: #ffffff;
--text-secondary: #f3f4f6;
--button-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
--shadow: 0 8px 32px rgba(31, 38, 135, 0.3);
--success-color: #22c55e;
--error-color: #ef4444;
--radius: 1.25rem;
}
/* ========================= RESET ========================== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
background: var(--background-gradient);
color: var(--text-primary);
display: flex;
flex-direction: column;
align-items: center;
padding: 1.5rem;
}
img,
svg {
max-width: 100%;
}
button,
input {
font: inherit;
}
/* ========================= HEADER ========================== */
.page-header {
text-align: center;
margin-bottom: 2rem;
max-width: 700px;
}
.page-title {
font-size: 2.5rem;
margin-bottom: 0.75rem;
}
.page-description {
color: var(--text-secondary);
line-height: 1.6;
}
/* ========================= MAIN LAYOUT ========================== */
.main-content {
width: 100%;
max-width: 900px;
display: grid;
gap: 1.5rem;
}
/* ========================= GLASS CARD ========================== */
.glass-card {
background: var(--glass-background);
border: 1px solid var(--glass-border);
backdrop-filter: blur(18px);
-webkit-backdrop-filter: blur(14px);
border-radius: var(--radius);
padding: 1.5rem;
box-shadow: var(--shadow);
}
/* ========================= FORM ========================== */
.form-title,
.result-title {
margin-bottom: 1rem;
font-size: 1.4rem;
}
.form-group {
margin-bottom: 1rem;
}
label {
display: block;
margin-bottom: 0.5rem;
font-weight: 600;
}
.input-wrapper {
display: flex;
gap: 0.75rem;
flex-wrap: wrap;
}
.token-input {
flex: 1;
min-width: 220px;
padding: 0.9rem 1rem;
border-radius: 0.9rem;
border: 1px solid rgba(255, 255, 255, 0.3);
background: rgba(255, 255, 255, 0.08);
color: var(--text-primary);
}
.token-input::placeholder {
color: rgba(255, 255, 255, 0.75);
}
.token-input:focus {
outline: 2px solid #ffffff;
outline-offset: 2px;
}
.secondary-button,
.primary-button {
border: none;
border-radius: 0.9rem;
cursor: pointer;
transition: transform 0.2s ease;
}
.secondary-button {
padding: 0.9rem 1rem;
background: rgba(255, 255, 255, 0.15);
color: white;
}
.primary-button {
width: 100%;
padding: 1rem;
margin-top: 0.5rem;
color: white;
font-weight: 600;
background: var(--button-gradient);
}
button:hover {
transform: translateY(-2px);
}
button:focus-visible {
outline: 2px solid #ffffff;
outline-offset: 3px;
}
/* ========================= RESULT SECTION ========================== */
.result-grid {
display: grid;
gap: 1rem;
}
.result-item {
background: rgba(255, 255, 255, 0.08);
border-radius: 0.8rem;
padding: 1rem;
}
.result-label {
display: block;
font-size: 0.9rem;
opacity: 0.8;
margin-bottom: 0.35rem;
}
.result-value {
font-weight: 600;
word-break: break-word;
}
.success {
color: var(--success-color);
}
.error {
color: var(--error-color);
}
.hidden {
display: none;
}
/* ========================= FOOTER ========================== */
.page-footer {
margin-top: 2rem;
text-align: center;
padding: 1rem;
}
.repo-link {
color: #ffffff;
font-weight: 600;
}
/* ========================= RESPONSIVE DESIGN ========================== */
@media (min-width: 768px) {
.result-grid {
grid-template-columns: repeat(2, 1fr);
}
}
/* ========================= DARK MODE SUPPORT ========================== */
@media (prefers-color-scheme: dark) {
:root {
--glass-background: rgba(0, 0, 0, 0.25);
}
}
</style>
</head>
<body>
<!-- ========================= HEADER ========================== -->
<header class="page-header">
<h1 class="page-title">GitHub Token Validator</h1>
<p class="page-description">Validate GitHub Personal Access Tokens instantly and view token owner, scopes, expiration date, and status.</p>
</header>
<!-- ========================= MAIN ========================== -->
<main class="main-content">
<section class="glass-card validator-section" aria-labelledby="validator-heading">
<h2 id="validator-heading" class="form-title">Enter Token</h2>
<form id="token-form">
<div class="form-group">
<label for="github-token-input"> GitHub Personal Access Token </label>
<div class="input-wrapper"><input id="github-token-input" class="token-input" type="password" placeholder="Paste your GitHub token" required /> <button type="button" id="toggle-token-visibility" class="secondary-button">Show</button></div>
</div>
<button type="submit" class="primary-button">Validate Token</button>
</form>
</section>
<section id="validation-results" class="glass-card hidden" aria-labelledby="result-heading">
<h2 id="result-heading" class="result-title">Validation Result</h2>
<div class="result-grid">
<div class="result-item"><span class="result-label">Status</span> <span id="token-status" class="result-value"> </span></div>
<div class="result-item"><span class="result-label">Owner</span> <span id="token-owner" class="result-value"> </span></div>
<div class="result-item"><span class="result-label">Username</span> <span id="token-username" class="result-value"> </span></div>
<div class="result-item"><span class="result-label">Scopes</span> <span id="token-scopes" class="result-value"> </span></div>
<div class="result-item"><span class="result-label">Expiry Date</span> <span id="token-expiry" class="result-value"> </span></div>
</div>
</section>
</main>
<!-- ========================= FOOTER ========================== -->
<footer class="page-footer">
<p>Built with ❤️ for One-File-Tools</p>
<a class="repo-link" href="https://github.com/praveenscience/One-File-Tools" target="_blank" rel="noopener noreferrer"> View Repository </a>
</footer>
<footer class="page-footer">
<p>Built with ❤️ for One-File-Tools</p>
<a class="repo-link" href="https://github.com/praveenscience/One-File-Tools" target="_blank" rel="noopener noreferrer"> View Repository </a>
</footer>
<script>
// ========================= // DOM ELEMENTS // =========================
const tokenForm = document.getElementById("token-form");
const tokenInput = document.getElementById("github-token-input");
const toggleVisibilityButton = document.getElementById("toggle-token-visibility");
const resultsSection = document.getElementById("validation-results");
const statusElement = document.getElementById("token-status");
const ownerElement = document.getElementById("token-owner");
const usernameElement = document.getElementById("token-username");
const scopesElement = document.getElementById("token-scopes");
const expiryElement = document.getElementById("token-expiry");
// ========================= // TOGGLE PASSWORD VISIBILITY // =========================
toggleVisibilityButton.addEventListener("click", () => {
const isPassword = tokenInput.type === "password";
tokenInput.type = isPassword ? "text" : "password";
toggleVisibilityButton.textContent = isPassword ? "Hide" : "Show";
});
// ========================= // FORM SUBMIT // =========================
tokenForm.addEventListener("submit", async (event) => {
event.preventDefault();
await validateToken();
});
// ========================= // VALIDATE TOKEN // =========================
const validateToken = async () => {
const token = tokenInput.value.trim();
if (!token) return;
try {
const response = await fetch("https://api.github.com/user", { headers: { Authorization: `Bearer ${token}` } });
const userData = await response.json();
updateResults(response, userData);
} catch (error) {
displayError("Unable to connect to GitHub API.");
}
};
// ========================= // UPDATE RESULT UI // =========================
const updateResults = (response, userData) => {
resultsSection.classList.remove("hidden");
if (response.ok) {
statusElement.textContent = "Valid ✅";
statusElement.className = "result-value success";
ownerElement.textContent = userData.name || "Not Public";
usernameElement.textContent = userData.login;
scopesElement.textContent = response.headers.get("X-OAuth-Scopes") || "No scopes found";
expiryElement.textContent = response.headers.get("GitHub-Authentication-Token-Expiration") || "No expiry information";
} else {
displayError("Invalid Token ❌");
}
};
// ========================= // SHOW ERROR // =========================
const displayError = (message) => {
resultsSection.classList.remove("hidden");
statusElement.textContent = message;
statusElement.className = "result-value error";
ownerElement.textContent = "-";
usernameElement.textContent = "-";
scopesElement.textContent = "-";
expiryElement.textContent = "-";
};
</script>
</body>
</html>