-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up debug HTML for development (#216)
Co-authored-by: frederikprijck <[email protected]>
- Loading branch information
1 parent
5be0715
commit 672f075
Showing
1 changed file
with
31 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,50 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Auth0 - JWT-Decode</title> | ||
<meta charset="utf-8" /> | ||
</head> | ||
|
||
<body> | ||
<h2>decoded:</h2> | ||
<pre><code class="js-decoded"></code></pre> | ||
<pre><code class="js-error1"></code></pre> | ||
<pre><code class="js-error2"></code></pre> | ||
<pre><code class="js-error3"></code></pre> | ||
|
||
<h2>Decoded:</h2> | ||
<pre><code id="js-decoded"></code></pre> | ||
<pre><code id="js-error1"></code></pre> | ||
<pre><code id="js-error2"></code></pre> | ||
<pre><code id="js-error3"></code></pre> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"jwt-decode": "/esm/index.js" | ||
} | ||
} | ||
</script> | ||
<script type="module"> | ||
import { jwtDecode } from "/esm/index.js"; | ||
var token = | ||
import { jwtDecode } from "jwt-decode"; | ||
|
||
const token = | ||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; | ||
var decoded = jwtDecode(token); | ||
document.querySelector(".js-decoded").innerHTML = JSON.stringify( | ||
decoded, | ||
null, | ||
4 | ||
); | ||
document.querySelector("#js-decoded").textContent = prettyJSON(jwtDecode(token)); | ||
|
||
var tokenError1 = | ||
"FAKE_TOKEN"; | ||
try { | ||
var decoded = jwtDecode(tokenError1); | ||
} catch (e) { | ||
document.querySelector(".js-error1").innerHTML = JSON.stringify( | ||
e, | ||
null, | ||
4 | ||
); | ||
jwtDecode("FAKE_TOKEN"); | ||
} catch (error) { | ||
document.querySelector("#js-error1").textContent = error.message; | ||
} | ||
|
||
var tokenError2 = | ||
"FAKE.TOKEN2"; | ||
try { | ||
var decoded = jwtDecode(tokenError2); | ||
} catch (e) { | ||
document.querySelector(".js-error2").innerHTML = JSON.stringify( | ||
e, | ||
null, | ||
4 | ||
); | ||
jwtDecode("FAKE.TOKEN2"); | ||
} catch (error) { | ||
document.querySelector("#js-error2").textContent = error.message; | ||
} | ||
|
||
var tokenError3 = | ||
"FAKE.TOKEN"; | ||
try { | ||
var decoded = jwtDecode(tokenError3); | ||
} catch (e) { | ||
document.querySelector(".js-error3").innerHTML = JSON.stringify( | ||
e, | ||
null, | ||
4 | ||
); | ||
jwtDecode("FAKE.TOKEN"); | ||
} catch (error) { | ||
document.querySelector("#js-error3").textContent = error.message; | ||
} | ||
|
||
function prettyJSON(data) { | ||
return JSON.stringify(data, null, 2); | ||
} | ||
</script> | ||
</body> | ||
</html> |