Upload jwt.html with huggingface_hub
Browse files
jwt.html
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>jwt.decode — Decode JWT tokens instantly</title>
|
| 7 |
+
<style>
|
| 8 |
+
*{margin:0;padding:0;box-sizing:border-box}
|
| 9 |
+
body{background:#0d1117;color:#c9d1d9;font-family:-apple-system,'Segoe UI',monospace;min-height:100vh;padding:3rem 1rem;display:flex;flex-direction:column;align-items:center}
|
| 10 |
+
h1{font-size:2rem;color:#f0f6fc;margin-bottom:.25rem}
|
| 11 |
+
.sub{color:#484f58;margin-bottom:2rem}
|
| 12 |
+
.panel{width:100%;max-width:700px}
|
| 13 |
+
label{color:#8b949e;font-size:.85rem;display:block;margin-bottom:.35rem;margin-top:1.25rem}
|
| 14 |
+
textarea{background:#161b22;border:1px solid #30363d;border-radius:6px;padding:.75rem 1rem;color:#f0f6fc;font-family:'Courier New',monospace;font-size:.85rem;outline:none;width:100%;min-height:100px;resize:vertical;line-height:1.5;word-break:break-all}
|
| 15 |
+
textarea:focus{border-color:#58a6ff}
|
| 16 |
+
.sections{display:flex;flex-direction:column;gap:1rem;margin-top:1.25rem}
|
| 17 |
+
.section{background:#161b22;border:1px solid #30363d;border-radius:8px;padding:1.25rem;overflow-x:auto}
|
| 18 |
+
.section h3{font-size:.85rem;margin-bottom:.75rem;text-transform:uppercase;letter-spacing:.05em}
|
| 19 |
+
.section h3.header-title{color:#f97583}
|
| 20 |
+
.section h3.payload-title{color:#79c0ff}
|
| 21 |
+
.section h3.sig-title{color:#56d364}
|
| 22 |
+
.section pre{font-family:'Courier New',monospace;font-size:.9rem;line-height:1.6;white-space:pre-wrap;word-break:break-all}
|
| 23 |
+
.key{color:#79c0ff}
|
| 24 |
+
.str{color:#a5d6ff}
|
| 25 |
+
.num{color:#d2a8ff}
|
| 26 |
+
.bool{color:#ff7b72}
|
| 27 |
+
.expiry{margin-top:.75rem;padding:.5rem .75rem;border-radius:4px;font-size:.85rem}
|
| 28 |
+
.expiry.valid{background:#0d2818;color:#3fb950;border:1px solid #238636}
|
| 29 |
+
.expiry.expired{background:#2d1117;color:#f85149;border:1px solid #da3633}
|
| 30 |
+
.error{color:#f85149;margin-top:1rem}
|
| 31 |
+
.parts{margin-top:.5rem}
|
| 32 |
+
.parts span{display:inline;word-break:break-all;font-family:'Courier New',monospace;font-size:.8rem}
|
| 33 |
+
.p1{color:#f97583}
|
| 34 |
+
.p2{color:#79c0ff}
|
| 35 |
+
.p3{color:#56d364}
|
| 36 |
+
.dot{color:#484f58}
|
| 37 |
+
.footer{margin-top:3rem;color:#30363d;font-size:.75rem}
|
| 38 |
+
</style>
|
| 39 |
+
</head>
|
| 40 |
+
<body>
|
| 41 |
+
<h1>jwt.decode</h1>
|
| 42 |
+
<p class="sub">Paste a token. See everything.</p>
|
| 43 |
+
|
| 44 |
+
<div class="panel">
|
| 45 |
+
<label>JWT Token</label>
|
| 46 |
+
<textarea id="token" placeholder="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"></textarea>
|
| 47 |
+
|
| 48 |
+
<div class="parts" id="parts"></div>
|
| 49 |
+
<div id="output"></div>
|
| 50 |
+
</div>
|
| 51 |
+
|
| 52 |
+
<div class="footer">Built by Atreus — dev.tools collection</div>
|
| 53 |
+
|
| 54 |
+
<script>
|
| 55 |
+
document.getElementById('token').addEventListener('input', decode);
|
| 56 |
+
|
| 57 |
+
function decode() {
|
| 58 |
+
const raw = document.getElementById('token').value.trim();
|
| 59 |
+
const partsEl = document.getElementById('parts');
|
| 60 |
+
const outEl = document.getElementById('output');
|
| 61 |
+
|
| 62 |
+
if (!raw) { partsEl.innerHTML = ''; outEl.innerHTML = ''; return; }
|
| 63 |
+
|
| 64 |
+
const segments = raw.split('.');
|
| 65 |
+
if (segments.length !== 3) {
|
| 66 |
+
partsEl.innerHTML = '';
|
| 67 |
+
outEl.innerHTML = '<div class="error">Not a valid JWT — expected 3 dot-separated parts (header.payload.signature)</div>';
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// Color the parts
|
| 72 |
+
partsEl.innerHTML = `<span class="p1">${segments[0]}</span><span class="dot">.</span><span class="p2">${segments[1]}</span><span class="dot">.</span><span class="p3">${segments[2]}</span>`;
|
| 73 |
+
|
| 74 |
+
let header, payload;
|
| 75 |
+
try {
|
| 76 |
+
header = JSON.parse(atob(segments[0].replace(/-/g,'+').replace(/_/g,'/')));
|
| 77 |
+
} catch(e) {
|
| 78 |
+
outEl.innerHTML = '<div class="error">Could not decode header (invalid base64)</div>';
|
| 79 |
+
return;
|
| 80 |
+
}
|
| 81 |
+
try {
|
| 82 |
+
payload = JSON.parse(atob(segments[1].replace(/-/g,'+').replace(/_/g,'/')));
|
| 83 |
+
} catch(e) {
|
| 84 |
+
outEl.innerHTML = '<div class="error">Could not decode payload (invalid base64)</div>';
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
let html = '<div class="sections">';
|
| 89 |
+
|
| 90 |
+
// Header
|
| 91 |
+
html += `<div class="section"><h3 class="header-title">Header</h3><pre>${colorJson(header)}</pre></div>`;
|
| 92 |
+
|
| 93 |
+
// Payload
|
| 94 |
+
let payloadExtra = '';
|
| 95 |
+
if (payload.exp) {
|
| 96 |
+
const expDate = new Date(payload.exp * 1000);
|
| 97 |
+
const now = new Date();
|
| 98 |
+
const isExpired = expDate < now;
|
| 99 |
+
const diff = Math.abs(expDate - now);
|
| 100 |
+
const days = Math.floor(diff / 86400000);
|
| 101 |
+
const hours = Math.floor((diff % 86400000) / 3600000);
|
| 102 |
+
const mins = Math.floor((diff % 3600000) / 60000);
|
| 103 |
+
let timeStr = '';
|
| 104 |
+
if (days > 0) timeStr += days + 'd ';
|
| 105 |
+
if (hours > 0) timeStr += hours + 'h ';
|
| 106 |
+
timeStr += mins + 'm';
|
| 107 |
+
payloadExtra = `<div class="expiry ${isExpired ? 'expired' : 'valid'}">${isExpired ? 'EXPIRED' : 'VALID'} — ${isExpired ? 'expired' : 'expires'} ${expDate.toLocaleString()} (${timeStr} ${isExpired ? 'ago' : 'from now'})</div>`;
|
| 108 |
+
}
|
| 109 |
+
if (payload.iat) {
|
| 110 |
+
const iatDate = new Date(payload.iat * 1000);
|
| 111 |
+
payloadExtra += `<div style="color:#8b949e;font-size:.8rem;margin-top:.35rem">Issued: ${iatDate.toLocaleString()}</div>`;
|
| 112 |
+
}
|
| 113 |
+
if (payload.nbf) {
|
| 114 |
+
const nbfDate = new Date(payload.nbf * 1000);
|
| 115 |
+
payloadExtra += `<div style="color:#8b949e;font-size:.8rem;margin-top:.2rem">Not before: ${nbfDate.toLocaleString()}</div>`;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
html += `<div class="section"><h3 class="payload-title">Payload</h3><pre>${colorJson(payload)}</pre>${payloadExtra}</div>`;
|
| 119 |
+
|
| 120 |
+
// Signature
|
| 121 |
+
html += `<div class="section"><h3 class="sig-title">Signature</h3><pre style="color:#56d364;font-size:.8rem;word-break:break-all">${segments[2]}</pre><div style="color:#8b949e;font-size:.8rem;margin-top:.5rem">Algorithm: ${header.alg || 'unknown'} — signature verification requires the secret key</div></div>`;
|
| 122 |
+
|
| 123 |
+
html += '</div>';
|
| 124 |
+
outEl.innerHTML = html;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function colorJson(obj) {
|
| 128 |
+
const str = JSON.stringify(obj, null, 2);
|
| 129 |
+
return str.replace(/"([^"]+)":/g, '<span class="key">"$1"</span>:')
|
| 130 |
+
.replace(/: "([^"]*)"(,?)/g, ': <span class="str">"$1"</span>$2')
|
| 131 |
+
.replace(/: (\d+)(,?)/g, ': <span class="num">$1</span>$2')
|
| 132 |
+
.replace(/: (true|false)(,?)/g, ': <span class="bool">$1</span>$2')
|
| 133 |
+
.replace(/: (null)(,?)/g, ': <span class="bool">$1</span>$2');
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
// Auto-decode if pasted
|
| 137 |
+
decode();
|
| 138 |
+
</script>
|
| 139 |
+
</body>
|
| 140 |
+
</html>
|