aboutsummaryrefslogtreecommitdiff
path: root/src/tools/jwt-parser/jwt-parser.vue
diff options
context:
space:
mode:
authorGravatar Corentin Thomasset <corentin.thomasset74@gmail.com> 2023-05-28 23:13:24 +0200
committerGravatar Corentin THOMASSET <corentin.thomasset74@gmail.com> 2023-05-28 23:29:14 +0200
commit33c9b6643f58a6930043f460d5bfdca4bc1f7222 (patch)
treef313935e30f7b90ea16e564e7171e2e72319ce29 /src/tools/jwt-parser/jwt-parser.vue
parent4d2b037dbe4e78aa90a4a6d9c7315dcf0a51fed9 (diff)
downloadit-tools-33c9b6643f58a6930043f460d5bfdca4bc1f7222.tar.gz
it-tools-33c9b6643f58a6930043f460d5bfdca4bc1f7222.tar.zst
it-tools-33c9b6643f58a6930043f460d5bfdca4bc1f7222.zip
chore(lint): switched to a better lint config
Diffstat (limited to 'src/tools/jwt-parser/jwt-parser.vue')
-rw-r--r--src/tools/jwt-parser/jwt-parser.vue66
1 files changed, 37 insertions, 29 deletions
diff --git a/src/tools/jwt-parser/jwt-parser.vue b/src/tools/jwt-parser/jwt-parser.vue
index 7a987b6..f3a460a 100644
--- a/src/tools/jwt-parser/jwt-parser.vue
+++ b/src/tools/jwt-parser/jwt-parser.vue
@@ -1,35 +1,9 @@
-<template>
- <c-card>
- <n-form-item label="JWT to decode" :feedback="validation.message" :validation-status="validation.status">
- <n-input v-model:value="rawJwt" type="textarea" placeholder="Put your token here..." rows="5" />
- </n-form-item>
-
- <n-table v-if="validation.isValid">
- <tbody>
- <template v-for="section of sections" :key="section.key">
- <th colspan="2" class="table-header">{{ section.title }}</th>
- <tr v-for="{ claim, claimDescription, friendlyValue, value } in decodedJWT[section.key]" :key="claim + value">
- <td class="claims">
- <n-text strong>{{ claim }}</n-text>
- <n-text v-if="claimDescription" depth="3" ml-2>({{ claimDescription }})</n-text>
- </td>
- <td>
- <n-text>{{ value }}</n-text>
- <n-text v-if="friendlyValue" ml-2 depth="3">({{ friendlyValue }})</n-text>
- </td>
- </tr>
- </template>
- </tbody>
- </n-table>
- </c-card>
-</template>
-
<script setup lang="ts">
+import { computed, ref } from 'vue';
+import { decodeJwt } from './jwt-parser.service';
import { useValidation } from '@/composable/validation';
import { isNotThrowing } from '@/utils/boolean';
import { withDefaultOnError } from '@/utils/defaults';
-import { computed, ref } from 'vue';
-import { decodeJwt } from './jwt-parser.service';
const rawJwt = ref(
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
@@ -48,13 +22,47 @@ const validation = useValidation({
source: rawJwt,
rules: [
{
- validator: (value) => value.length > 0 && isNotThrowing(() => decodeJwt({ jwt: rawJwt.value })),
+ validator: value => value.length > 0 && isNotThrowing(() => decodeJwt({ jwt: rawJwt.value })),
message: 'Invalid JWT',
},
],
});
</script>
+<template>
+ <c-card>
+ <n-form-item label="JWT to decode" :feedback="validation.message" :validation-status="validation.status">
+ <n-input v-model:value="rawJwt" type="textarea" placeholder="Put your token here..." rows="5" />
+ </n-form-item>
+
+ <n-table v-if="validation.isValid">
+ <tbody>
+ <template v-for="section of sections" :key="section.key">
+ <th colspan="2" class="table-header">
+ {{ section.title }}
+ </th>
+ <tr v-for="{ claim, claimDescription, friendlyValue, value } in decodedJWT[section.key]" :key="claim + value">
+ <td class="claims">
+ <n-text strong>
+ {{ claim }}
+ </n-text>
+ <n-text v-if="claimDescription" depth="3" ml-2>
+ ({{ claimDescription }})
+ </n-text>
+ </td>
+ <td>
+ <n-text>{{ value }}</n-text>
+ <n-text v-if="friendlyValue" ml-2 depth="3">
+ ({{ friendlyValue }})
+ </n-text>
+ </td>
+ </tr>
+ </template>
+ </tbody>
+ </n-table>
+ </c-card>
+</template>
+
<style lang="less" scoped>
.table-header {
text-align: center;