-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathgithub-token-validator-modern.html
More file actions
620 lines (584 loc) · 19.5 KB
/
Copy pathgithub-token-validator-modern.html
File metadata and controls
620 lines (584 loc) · 19.5 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>octocheck — Token Validator</title>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700;800&family=Fragment+Mono&display=swap" rel="stylesheet" />
<style>
:root {
--bg-0: #06070a;
--bg-1: #0d0f15;
--bg-2: #12151e;
--bg-3: #181c29;
--line: #23273a;
--line-bright: #343b59;
--ink-0: #eef0f8;
--ink-1: #8b92b3;
--ink-2: #52597a;
--green: #3ddc84;
--green-dim: #1f8a51;
--red: #ff5c7a;
--amber: #ffb454;
--blue: #5b9dff;
--mono: "JetBrains Mono", monospace;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
}
body {
background: radial-gradient(circle 600px at 50% -8%, rgba(61, 220, 132, 0.08), transparent 60%), var(--bg-0);
color: var(--ink-0);
font-family: var(--mono);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 32px 18px;
-webkit-font-smoothing: antialiased;
}
.wrap {
width: 100%;
max-width: 560px;
}
.terminal-frame {
background: var(--bg-1);
border: 1px solid var(--line);
border-radius: 14px;
overflow: hidden;
box-shadow:
0 30px 70px -20px rgba(0, 0, 0, 0.7),
0 0 0 1px rgba(255, 255, 255, 0.02);
}
.term-bar {
display: flex;
align-items: center;
gap: 8px;
padding: 13px 16px;
background: var(--bg-2);
border-bottom: 1px solid var(--line);
}
.tdot {
width: 10px;
height: 10px;
border-radius: 50%;
}
.tdot.r {
background: #ff5f57;
}
.tdot.y {
background: #febc2e;
}
.tdot.g {
background: #28c840;
}
.term-title {
flex: 1;
text-align: center;
font-size: 11.5px;
color: var(--ink-2);
letter-spacing: 0.04em;
margin-right: 42px;
}
.content {
padding: 30px 28px 26px;
}
.brand-row {
display: flex;
align-items: center;
gap: 14px;
margin-bottom: 24px;
}
.brand-icon {
width: 46px;
height: 46px;
border-radius: 11px;
background: var(--bg-3);
border: 1px solid var(--line-bright);
display: flex;
align-items: center;
justify-content: center;
box-shadow:
0 0 0 1px rgba(61, 220, 132, 0.08),
inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.brand-text h1 {
font-size: 17px;
margin: 0;
font-weight: 700;
letter-spacing: -0.01em;
}
.brand-text p {
font-size: 12px;
margin: 3px 0 0;
color: var(--ink-2);
}
.prompt-line {
font-size: 12.5px;
color: var(--ink-2);
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 7px;
}
.prompt-line .car {
color: var(--green);
font-weight: 700;
}
.field-wrap {
position: relative;
}
.token-field {
width: 100%;
background: var(--bg-0);
border: 1px solid var(--line);
border-radius: 10px;
padding: 14px 88px 14px 16px;
font-family: var(--mono);
font-size: 14px;
color: var(--ink-0);
outline: none;
letter-spacing: 0.02em;
transition:
border-color 0.15s ease,
box-shadow 0.15s ease;
}
.token-field:focus {
border-color: var(--green-dim);
box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.1);
}
.token-field::placeholder {
color: var(--ink-2);
}
.field-actions {
position: absolute;
right: 6px;
top: 50%;
transform: translateY(-50%);
display: flex;
gap: 4px;
}
.icon-btn {
background: transparent;
border: none;
color: var(--ink-2);
width: 30px;
height: 30px;
border-radius: 7px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s ease;
}
.icon-btn:hover {
background: var(--bg-3);
color: var(--ink-0);
}
.submit-btn {
width: 100%;
margin-top: 14px;
background: linear-gradient(180deg, #2bbd6f, var(--green-dim));
border: 1px solid #1f8a51;
color: #06140c;
font-family: var(--mono);
font-weight: 800;
font-size: 13.5px;
padding: 13px;
border-radius: 10px;
cursor: pointer;
letter-spacing: 0.02em;
display: flex;
align-items: center;
justify-content: center;
gap: 9px;
box-shadow:
0 8px 20px -8px rgba(61, 220, 132, 0.5),
inset 0 1px 0 rgba(255, 255, 255, 0.2);
transition:
transform 0.1s ease,
box-shadow 0.15s ease;
}
.submit-btn:hover {
transform: translateY(-1px);
box-shadow:
0 10px 26px -8px rgba(61, 220, 132, 0.65),
inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.submit-btn:active {
transform: translateY(0);
}
.submit-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.spinner {
width: 14px;
height: 14px;
border-radius: 50%;
border: 2px solid rgba(6, 20, 12, 0.3);
border-top-color: #06140c;
animation: spin 0.7s linear infinite;
display: none;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
/* result */
.result {
margin-top: 22px;
border-radius: 12px;
overflow: hidden;
max-height: 0;
opacity: 0;
transition:
max-height 0.35s ease,
opacity 0.35s ease,
margin 0.35s ease;
}
.result.open {
max-height: 900px;
opacity: 1;
}
.result-inner {
border: 1px solid var(--line);
border-radius: 12px;
background: var(--bg-0);
overflow: hidden;
}
.status-strip {
display: flex;
align-items: center;
gap: 10px;
padding: 13px 16px;
border-bottom: 1px solid var(--line);
}
.status-strip.ok {
background: rgba(61, 220, 132, 0.06);
}
.status-strip.err {
background: rgba(255, 92, 122, 0.06);
}
.status-strip svg {
flex-shrink: 0;
}
.status-strip .label {
font-weight: 700;
font-size: 13px;
}
.status-strip.ok .label {
color: var(--green);
}
.status-strip.err .label {
color: var(--red);
}
.status-strip .sub {
font-size: 11px;
color: var(--ink-2);
margin-left: auto;
}
.user-block {
padding: 16px;
display: flex;
gap: 13px;
align-items: center;
border-bottom: 1px solid var(--line);
}
.user-avatar {
width: 48px;
height: 48px;
border-radius: 10px;
border: 1px solid var(--line-bright);
}
.user-name {
font-weight: 700;
font-size: 14.5px;
}
.user-login {
font-size: 12.5px;
color: var(--blue);
text-decoration: none;
}
.user-login:hover {
text-decoration: underline;
}
.meta-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1px;
background: var(--line);
}
.meta-cell {
background: var(--bg-0);
padding: 13px 16px;
}
.meta-label {
font-size: 9.5px;
letter-spacing: 0.09em;
text-transform: uppercase;
color: var(--ink-2);
margin-bottom: 6px;
font-weight: 700;
}
.meta-val {
font-size: 12.5px;
color: var(--ink-0);
font-weight: 600;
word-break: break-word;
}
.scope-tags {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.scope-tag {
background: rgba(91, 157, 255, 0.12);
border: 1px solid rgba(91, 157, 255, 0.3);
color: var(--blue);
font-size: 10.5px;
font-weight: 700;
padding: 3px 8px;
border-radius: 5px;
}
.scope-tag.none {
background: var(--bg-3);
border-color: var(--line);
color: var(--ink-2);
}
.rate-bar-track {
height: 6px;
background: var(--bg-3);
border-radius: 3px;
overflow: hidden;
margin-top: 8px;
}
.rate-bar-fill {
height: 100%;
background: linear-gradient(90deg, var(--green), var(--amber));
border-radius: 3px;
transition: width 0.4s ease;
}
.error-block {
padding: 16px;
font-size: 12.5px;
color: var(--red);
line-height: 1.6;
}
.footer-note {
text-align: center;
margin-top: 18px;
font-size: 11px;
color: var(--ink-2);
display: flex;
align-items: center;
justify-content: center;
gap: 6px;
}
.footer-note svg {
flex-shrink: 0;
}
.scanline {
position: absolute;
left: 0;
right: 0;
top: 0;
height: 2px;
background: linear-gradient(90deg, transparent, var(--green), transparent);
opacity: 0;
}
.scanline.run {
animation: scan 1s ease-out;
}
@keyframes scan {
0% {
top: 0;
opacity: 1;
}
100% {
top: 100%;
opacity: 0;
}
}
</style>
</head>
<body>
<div class="wrap">
<div class="terminal-frame" style="position: relative">
<div class="scanline" id="scanline"></div>
<div class="term-bar">
<span class="tdot r"></span><span class="tdot y"></span><span class="tdot g"></span>
<span class="term-title">~/auth/validate-token</span>
</div>
<div class="content">
<div class="brand-row">
<div class="brand-icon">
<svg width="24" height="24" fill="#3ddc84" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" /></svg>
</div>
<div class="brand-text">
<h1>octocheck</h1>
<p>Validate a GitHub token without it ever leaving your browser</p>
</div>
</div>
<div class="prompt-line"><span class="car">❯</span> paste your personal access token</div>
<form id="tokenForm">
<div class="field-wrap">
<input type="password" id="tokenInput" class="token-field" placeholder="ghp_••••••••••••••••••••••••••••" required autocomplete="off" spellcheck="false" />
<div class="field-actions">
<button type="button" class="icon-btn" id="toggleVis" title="Show token">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8">
<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z" />
<circle cx="12" cy="12" r="3" />
</svg>
</button>
</div>
</div>
<button type="submit" class="submit-btn" id="submitBtn">
<span class="spinner" id="spinner"></span>
<span id="btnText">Validate token</span>
</button>
</form>
<div class="result" id="result">
<div class="result-inner" id="resultInner"></div>
</div>
<div class="footer-note">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<rect x="3" y="11" width="18" height="11" rx="2" />
<path d="M7 11V7a5 5 0 0110 0v4" />
</svg>
Sent directly to api.github.com · nothing is stored or logged
</div>
</div>
</div>
</div>
<script>
const form = document.getElementById("tokenForm");
const tokenInput = document.getElementById("tokenInput");
const toggleVis = document.getElementById("toggleVis");
const submitBtn = document.getElementById("submitBtn");
const spinner = document.getElementById("spinner");
const btnText = document.getElementById("btnText");
const result = document.getElementById("result");
const resultInner = document.getElementById("resultInner");
const scanline = document.getElementById("scanline");
toggleVis.addEventListener("click", () => {
const isPw = tokenInput.type === "password";
tokenInput.type = isPw ? "text" : "password";
toggleVis.innerHTML = isPw ? '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M17.94 17.94A10.94 10.94 0 0112 19c-7 0-11-7-11-7a18.5 18.5 0 015.06-5.94M9.9 4.24A10.94 10.94 0 0112 5c7 0 11 7 11 7a18.5 18.5 0 01-2.16 3.19M14.12 14.12a3 3 0 11-4.24-4.24"/><path d="M1 1l22 22"/></svg>' : '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z"/><circle cx="12" cy="12" r="3"/></svg>';
});
function escapeHTML(str) {
return String(str).replace(/[&<>'"]/g, (t) => ({ "&": "&", "<": "<", ">": ">", "'": "'", '"': """ })[t]);
}
function setLoading(loading) {
submitBtn.disabled = loading;
spinner.style.display = loading ? "inline-block" : "none";
btnText.textContent = loading ? "Validating…" : "Validate token";
}
function relTime(sec) {
if (sec <= 0) return "now";
const m = Math.floor(sec / 60),
s = sec % 60;
return m > 0 ? `${m}m ${s}s` : `${s}s`;
}
function renderSuccess(user, scopesHeader, rateLimit) {
const scopes = scopesHeader
? scopesHeader
.split(",")
.map((s) => s.trim())
.filter(Boolean)
: [];
const scopeHTML = scopes.length ? scopes.map((s) => `<span class="scope-tag">${escapeHTML(s)}</span>`).join("") : `<span class="scope-tag none">no scopes · fine-grained or read:user only</span>`;
const limit = rateLimit.limit,
remaining = rateLimit.remaining,
resetSec = rateLimit.resetSec;
const pct = limit ? Math.max(2, Math.round((remaining / limit) * 100)) : 0;
resultInner.innerHTML = `
<div class="status-strip ok">
<svg width="18" height="18" viewBox="0 0 20 20" fill="#3ddc84"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.7-9.3a1 1 0 00-1.4-1.4L9 10.6 7.7 9.3a1 1 0 00-1.4 1.4l2 2a1 1 0 001.4 0l4-4z" clip-rule="evenodd"/></svg>
<span class="label">Token is valid</span>
<span class="sub">${user.type === "Bot" ? "Bot account" : "authenticated as user"}</span>
</div>
<div class="user-block">
<img class="user-avatar" src="${user.avatar_url}" alt="">
<div>
<div class="user-name">${escapeHTML(user.name || user.login)}</div>
<a class="user-login" href="${user.html_url}" target="_blank" rel="noopener">@${escapeHTML(user.login)}</a>
</div>
</div>
<div class="meta-grid">
<div class="meta-cell" style="grid-column:1/-1;">
<div class="meta-label">OAuth scopes</div>
<div class="scope-tags">${scopeHTML}</div>
</div>
<div class="meta-cell">
<div class="meta-label">Public repos</div>
<div class="meta-val">${user.public_repos ?? "—"}</div>
</div>
<div class="meta-cell">
<div class="meta-label">Account created</div>
<div class="meta-val">${user.created_at ? new Date(user.created_at).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : "—"}</div>
</div>
<div class="meta-cell" style="grid-column:1/-1;">
<div class="meta-label">API rate limit</div>
<div class="meta-val">${remaining ?? "—"} / ${limit ?? "—"} requests remaining · resets in ${resetSec != null ? relTime(resetSec) : "—"}</div>
${limit ? `<div class="rate-bar-track"><div class="rate-bar-fill" style="width:${pct}%"></div></div>` : ""}
</div>
</div>
`;
}
function renderError(message, status) {
resultInner.innerHTML = `
<div class="status-strip err">
<svg width="18" height="18" viewBox="0 0 20 20" fill="#ff5c7a"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.7 7.3a1 1 0 00-1.4 1.4L8.6 10l-1.3 1.3a1 1 0 101.4 1.4L10 11.4l1.3 1.3a1 1 0 001.4-1.4L11.4 10l1.3-1.3a1 1 0 00-1.4-1.4L10 8.6 8.7 7.3z" clip-rule="evenodd"/></svg>
<span class="label">Validation failed</span>
${status ? `<span class="sub">HTTP ${status}</span>` : ""}
</div>
<div class="error-block">${escapeHTML(message)}</div>
`;
}
form.addEventListener("submit", async (e) => {
e.preventDefault();
const token = tokenInput.value.trim();
if (!token) return;
setLoading(true);
result.classList.remove("open");
scanline.classList.remove("run");
void scanline.offsetWidth;
scanline.classList.add("run");
try {
const res = await fetch("https://api.github.com/user", {
headers: {
Authorization: `Bearer ${token}`,
Accept: "application/vnd.github+json",
"X-GitHub-Api-Version": "2022-11-28"
}
});
const limit = res.headers.get("x-ratelimit-limit");
const remaining = res.headers.get("x-ratelimit-remaining");
const reset = res.headers.get("x-ratelimit-reset");
const resetSec = reset ? Math.max(0, Math.floor(reset - Date.now() / 1000)) : null;
const scopes = res.headers.get("x-oauth-scopes");
if (!res.ok) {
const msg = res.status === 401 ? "Bad credentials — the token is invalid, expired, or revoked." : `Unexpected response (${res.statusText}).`;
renderError(msg, res.status);
} else {
const user = await res.json();
renderSuccess(user, scopes, { limit, remaining, resetSec });
}
} catch (err) {
renderError("Could not reach api.github.com — check your connection and try again.");
} finally {
setLoading(false);
requestAnimationFrame(() => result.classList.add("open"));
}
});
</script>
</body>
</html>