|
29 | 29 | Show claim information
|
30 | 30 | </label>
|
31 | 31 | </div>
|
32 |
| - <div class="custom-control custom-switch custom-control-inline"> |
| 32 | + <div class="custom-control custom-switch custom-control-inline d-none d-md-inline-flex"> |
33 | 33 | <input class="custom-control-input" type="checkbox" id="togglePresenterMode">
|
34 | 34 | <label class="custom-control-label" for="togglePresenterMode">
|
35 | 35 | Presenter mode
|
|
43 | 43 | <div class="h-100 d-flex flex-column">
|
44 | 44 | <div class="form-group flex-grow-1">
|
45 | 45 | <label for="jwt-input" class="sr-only">Paste your JWT here...</label>
|
46 |
| - <div id="jwt-input" class="form-control bg-dark text-light p-2 h-100 jwt-input-editable" contenteditable="true" rows="8" style="min-height: 10em;" placeholder="Paste your JWT here..."></div> |
| 46 | + <div id="jwt-input" class="form-control bg-dark text-light p-2 h-100 jwt-input-editable" contenteditable="true" rows="8" style="min-height: 10em;" placeholder="Paste your JWT here...">@Model.View?.Token</div> |
47 | 47 | </div>
|
48 | 48 | <div class="form-group">
|
49 | 49 | <label for="jwks-url">Issuer, Discovery Document or JWKs URI</label>
|
50 |
| - <input type="url" class="form-control mb-2 mr-sm-2" id="jwks-url" name="jwks-url" aria-describedby="jwks-url-help" data-pristine="true" /> |
| 50 | + <input type="url" class="form-control mb-2 mr-sm-2 bg-dark text-light" id="jwks-url" name="jwks-url" aria-describedby="jwks-url-help" data-pristine="true" /> |
51 | 51 | <small id="jwks-url-help" class="form-text text-muted">
|
52 | 52 | Optionally, you can provide the issuer, discovery document or JWKs URI to validate the JWT's signature.
|
53 | 53 | If you leave this field empty, the tool will use the value of the 'iss' claim.
|
|
114 | 114 | case 'kid':
|
115 | 115 | return '// Key ID, identifying which key was used to sign the JWT';
|
116 | 116 | case 'typ':
|
117 |
| - return '// Type of the token, typically "JWT"'; |
| 117 | + return `// Token type: ${explainTokenType(value)}`; |
118 | 118 | case 'cty':
|
119 | 119 | return '// Content type, similar to MIME type, indicating the media type of the JWT.';
|
120 | 120 | case 'jwk':
|
|
233 | 233 | }
|
234 | 234 | }
|
235 | 235 |
|
| 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 | + |
236 | 256 | function convertEpoch(epoch) {
|
237 | 257 | if (typeof epoch === 'number') {
|
238 | 258 | const date = new Date(epoch * 1000);
|
|
307 | 327 | }
|
308 | 328 | });
|
309 | 329 |
|
310 |
| - $('#jwt-input').on('input', async function() { |
| 330 | + const jwtInput = $('#jwt-input'); |
| 331 | + jwtInput.on('input', async function() { |
311 | 332 | decodedJwt = {
|
312 | 333 | header: null,
|
313 | 334 | payload: null,
|
|
341 | 362 | }
|
342 | 363 | });
|
343 | 364 |
|
344 |
| - await showDecodedJwt(null, null, null, ' '); |
| 365 | + @if (Model.View?.Token != null) |
| 366 | + { |
| 367 | + @:jwtInput.trigger('input'); // Trigger input event to decode the JWT if it was provided |
| 368 | + } |
| 369 | + else |
| 370 | + { |
| 371 | + @:await showDecodedJwt(null, null, null, ' '); |
| 372 | + } |
345 | 373 | }
|
346 | 374 |
|
347 | 375 | function colorJwtInput(target, parts) {
|
|
0 commit comments