mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-22 15:56:15 -04:00
added base tool structure
This commit is contained in:
parent
3e4a64551f
commit
bb0eca80a7
4 changed files with 42 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { LockOpen } from '@vicons/tabler';
|
import { LockOpen } from '@vicons/tabler';
|
||||||
import type { ToolCategory } from './tool';
|
import type { ToolCategory } from './tool';
|
||||||
|
|
||||||
|
import { tool as jwtParser } from './jwt-parser';
|
||||||
import { tool as mimeTypes } from './mime-types';
|
import { tool as mimeTypes } from './mime-types';
|
||||||
import { tool as otpCodeGeneratorAndValidator } from './otp-code-generator-and-validator';
|
import { tool as otpCodeGeneratorAndValidator } from './otp-code-generator-and-validator';
|
||||||
import { tool as base64FileConverter } from './base64-file-converter';
|
import { tool as base64FileConverter } from './base64-file-converter';
|
||||||
|
@ -67,6 +68,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||||
metaTagGenerator,
|
metaTagGenerator,
|
||||||
otpCodeGeneratorAndValidator,
|
otpCodeGeneratorAndValidator,
|
||||||
mimeTypes,
|
mimeTypes,
|
||||||
|
jwtParser,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
11
src/tools/jwt-parser/index.ts
Normal file
11
src/tools/jwt-parser/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { ArrowsShuffle } from '@vicons/tabler';
|
||||||
|
import { defineTool } from '../tool';
|
||||||
|
|
||||||
|
export const tool = defineTool({
|
||||||
|
name: 'JWT parser',
|
||||||
|
path: '/jwt-parser',
|
||||||
|
description: '',
|
||||||
|
keywords: ['jwt', 'parser'],
|
||||||
|
component: () => import('./jwt-parser.vue'),
|
||||||
|
icon: ArrowsShuffle,
|
||||||
|
});
|
20
src/tools/jwt-parser/jwt-parser.service.ts
Normal file
20
src/tools/jwt-parser/jwt-parser.service.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import jwt_decode, { InvalidTokenError } from 'jwt-decode';
|
||||||
|
|
||||||
|
interface JWT {
|
||||||
|
header: Map<string, unknown>;
|
||||||
|
payload: Map<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function safe_jwt_decode(raw_jwt: string): JWT {
|
||||||
|
try {
|
||||||
|
const header = jwt_decode(raw_jwt, { header: true }) as Map<string, unknown>;
|
||||||
|
const payload = jwt_decode(raw_jwt) as Map<string, unknown>;
|
||||||
|
return { header: header, payload: payload };
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof InvalidTokenError) {
|
||||||
|
return { header: new Map<string, unknown>(), payload: new Map<string, unknown>() };
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
src/tools/jwt-parser/jwt-parser.vue
Normal file
9
src/tools/jwt-parser/jwt-parser.vue
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<template>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
Loading…
Add table
Add a link
Reference in a new issue