Skip to content

Commit 4c171c1

Browse files
committed
Improved explanation of the typ claim value
1 parent bdfa3cc commit 4c171c1

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Pages/Home/JwtDecoder/JwtDecoder.cshtml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
case 'kid':
115115
return '// Key ID, identifying which key was used to sign the JWT';
116116
case 'typ':
117-
return '// Type of the token, typically "JWT"';
117+
return `// Token type: ${explainTokenType(value)}`;
118118
case 'cty':
119119
return '// Content type, similar to MIME type, indicating the media type of the JWT.';
120120
case 'jwk':
@@ -233,6 +233,26 @@
233233
}
234234
}
235235
236+
function explainTokenType(type) {
237+
switch (type.toLowerCase()) {
238+
case 'jwt':
239+
case 'http://openid.net/specs/jwt/1.0':
240+
return 'JSON Web Token';
241+
case 'jws':
242+
return 'JSON Web Signature, a signed JWT';
243+
case 'jwe':
244+
return 'JSON Web Encryption, an encrypted JWT';
245+
case 'at+jwt':
246+
return 'Access Token';
247+
case 'token-introspection+jwt':
248+
return 'JWT response from the Introspection endpoint';
249+
case 'secevent+jwt':
250+
return 'Security Event Token';
251+
default:
252+
return type;
253+
}
254+
}
255+
236256
function convertEpoch(epoch) {
237257
if (typeof epoch === 'number') {
238258
const date = new Date(epoch * 1000);

0 commit comments

Comments
 (0)