mirror of
https://github.com/sharevb/it-tools.git
synced 2026-11-24 14:50:17 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c23a129941 |
No files matched your search
Vendored
+3
-8
@@ -23,7 +23,6 @@ declare module '@vue/runtime-core' {
|
||||
CAlert: typeof import('./src/ui/c-alert/c-alert.vue')['default']
|
||||
'CAlert.demo': typeof import('./src/ui/c-alert/c-alert.demo.vue')['default']
|
||||
CameraRecorder: typeof import('./src/tools/camera-recorder/camera-recorder.vue')['default']
|
||||
CardPicker: typeof import('./src/tools/card-picker/card-picker.vue')['default']
|
||||
CaseConverter: typeof import('./src/tools/case-converter/case-converter.vue')['default']
|
||||
CButton: typeof import('./src/ui/c-button/c-button.vue')['default']
|
||||
'CButton.demo': typeof import('./src/ui/c-button/c-button.demo.vue')['default']
|
||||
@@ -51,7 +50,6 @@ declare module '@vue/runtime-core' {
|
||||
'CModal.demo': typeof import('./src/ui/c-modal/c-modal.demo.vue')['default']
|
||||
CModalValue: typeof import('./src/ui/c-modal-value/c-modal-value.vue')['default']
|
||||
'CModalValue.demo': typeof import('./src/ui/c-modal-value/c-modal-value.demo.vue')['default']
|
||||
CoinFlipper: typeof import('./src/tools/coin-flipper/coin-flipper.vue')['default']
|
||||
CollapsibleToolMenu: typeof import('./src/components/CollapsibleToolMenu.vue')['default']
|
||||
ColorConverter: typeof import('./src/tools/color-converter/color-converter.vue')['default']
|
||||
ColoredCard: typeof import('./src/components/ColoredCard.vue')['default']
|
||||
@@ -70,7 +68,6 @@ declare module '@vue/runtime-core' {
|
||||
'DemoHome.page': typeof import('./src/ui/demo/demo-home.page.vue')['default']
|
||||
DemoWrapper: typeof import('./src/ui/demo/demo-wrapper.vue')['default']
|
||||
DeviceInformation: typeof import('./src/tools/device-information/device-information.vue')['default']
|
||||
DiceRoller: typeof import('./src/tools/dice-roller/dice-roller.vue')['default']
|
||||
DiffViewer: typeof import('./src/tools/json-diff/diff-viewer/diff-viewer.vue')['default']
|
||||
DockerRunToDockerComposeConverter: typeof import('./src/tools/docker-run-to-docker-compose-converter/docker-run-to-docker-compose-converter.vue')['default']
|
||||
DynamicValues: typeof import('./src/tools/benchmark-builder/dynamic-values.vue')['default']
|
||||
@@ -83,7 +80,6 @@ declare module '@vue/runtime-core' {
|
||||
EtaCalculator: typeof import('./src/tools/eta-calculator/eta-calculator.vue')['default']
|
||||
FavoriteButton: typeof import('./src/components/FavoriteButton.vue')['default']
|
||||
FormatTransformer: typeof import('./src/components/FormatTransformer.vue')['default']
|
||||
FortuneWheel: typeof import('./src/tools/fortune-wheel/fortune-wheel.vue')['default']
|
||||
GitMemo: typeof import('./src/tools/git-memo/git-memo.vue')['default']
|
||||
'GitMemo.content': typeof import('./src/tools/git-memo/git-memo.content.md')['default']
|
||||
HashText: typeof import('./src/tools/hash-text/hash-text.vue')['default']
|
||||
@@ -118,6 +114,7 @@ declare module '@vue/runtime-core' {
|
||||
JsonToXml: typeof import('./src/tools/json-to-xml/json-to-xml.vue')['default']
|
||||
JsonToYaml: typeof import('./src/tools/json-to-yaml-converter/json-to-yaml.vue')['default']
|
||||
JsonViewer: typeof import('./src/tools/json-viewer/json-viewer.vue')['default']
|
||||
JwtGenerator: typeof import('./src/tools/jwt-generator/jwt-generator.vue')['default']
|
||||
JwtParser: typeof import('./src/tools/jwt-parser/jwt-parser.vue')['default']
|
||||
KeycodeInfo: typeof import('./src/tools/keycode-info/keycode-info.vue')['default']
|
||||
ListConverter: typeof import('./src/tools/list-converter/list-converter.vue')['default']
|
||||
@@ -133,14 +130,14 @@ declare module '@vue/runtime-core' {
|
||||
MenuLayout: typeof import('./src/components/MenuLayout.vue')['default']
|
||||
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
|
||||
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
|
||||
NA: typeof import('naive-ui')['NA']
|
||||
NAlert: typeof import('naive-ui')['NAlert']
|
||||
NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default']
|
||||
NCheckbox: typeof import('naive-ui')['NCheckbox']
|
||||
NCode: typeof import('naive-ui')['NCode']
|
||||
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
|
||||
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
|
||||
NDivider: typeof import('naive-ui')['NDivider']
|
||||
NEllipsis: typeof import('naive-ui')['NEllipsis']
|
||||
NForm: typeof import('naive-ui')['NForm']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NH1: typeof import('naive-ui')['NH1']
|
||||
NH3: typeof import('naive-ui')['NH3']
|
||||
@@ -149,9 +146,7 @@ declare module '@vue/runtime-core' {
|
||||
NLayout: typeof import('naive-ui')['NLayout']
|
||||
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
|
||||
NMenu: typeof import('naive-ui')['NMenu']
|
||||
NP: typeof import('naive-ui')['NP']
|
||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||
NSpace: typeof import('naive-ui')['NSpace']
|
||||
NTable: typeof import('naive-ui')['NTable']
|
||||
NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default']
|
||||
OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default']
|
||||
|
||||
+1
-3
@@ -37,7 +37,6 @@
|
||||
"release": "node ./scripts/release.mjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dice-roller/rpg-dice-roller": "^5.5.1",
|
||||
"@it-tools/bip39": "^0.0.4",
|
||||
"@it-tools/oggen": "^1.3.0",
|
||||
"@regexper/render": "^1.0.0",
|
||||
@@ -53,7 +52,6 @@
|
||||
"@vueuse/core": "^10.3.0",
|
||||
"@vueuse/head": "^1.0.0",
|
||||
"@vueuse/router": "^10.0.0",
|
||||
"@younestouati/playing-cards-standard-deck": "^6.0.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"change-case": "^4.1.2",
|
||||
"colord": "^2.9.3",
|
||||
@@ -72,6 +70,7 @@
|
||||
"highlight.js": "^11.7.0",
|
||||
"iarna-toml-esm": "^3.0.5",
|
||||
"ibantools": "^4.3.3",
|
||||
"jose": "^5.9.6",
|
||||
"js-base64": "^3.7.6",
|
||||
"json5": "^2.2.3",
|
||||
"jwt-decode": "^3.1.2",
|
||||
@@ -102,7 +101,6 @@
|
||||
"vue-router": "^4.1.6",
|
||||
"vue-shadow-dom": "^4.2.0",
|
||||
"vue-tsc": "^1.8.1",
|
||||
"vue3-fortune-wheel": "^2.0.5",
|
||||
"vuedraggable": "^4.1.0",
|
||||
"xml-formatter": "^3.3.2",
|
||||
"xml-js": "^1.6.11",
|
||||
|
||||
Generated
+1285
-1310
File diff suppressed because it is too large.
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
@@ -7,8 +7,15 @@ import sqlHljs from 'highlight.js/lib/languages/sql';
|
||||
import xmlHljs from 'highlight.js/lib/languages/xml';
|
||||
import yamlHljs from 'highlight.js/lib/languages/yaml';
|
||||
import iniHljs from 'highlight.js/lib/languages/ini';
|
||||
import bashHljs from 'highlight.js/lib/languages/bash';
|
||||
import markdownHljs from 'highlight.js/lib/languages/markdown';
|
||||
import jsHljs from 'highlight.js/lib/languages/javascript';
|
||||
import cssHljs from 'highlight.js/lib/languages/css';
|
||||
import goHljs from 'highlight.js/lib/languages/go';
|
||||
import csharpHljs from 'highlight.js/lib/languages/csharp';
|
||||
import { Base64 } from 'js-base64';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useDownloadFileFromBase64 } from '@/composable/downloadBase64';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -17,12 +24,17 @@ const props = withDefaults(
|
||||
language?: string
|
||||
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
|
||||
copyMessage?: string
|
||||
wordWrap?: boolean
|
||||
downloadFileName?: string
|
||||
downloadButtonText?: string
|
||||
}>(),
|
||||
{
|
||||
followHeightOf: null,
|
||||
language: 'txt',
|
||||
copyPlacement: 'top-right',
|
||||
copyMessage: 'Copy to clipboard',
|
||||
downloadFileName: '',
|
||||
downloadButtonText: 'Download',
|
||||
},
|
||||
);
|
||||
hljs.registerLanguage('sql', sqlHljs);
|
||||
@@ -31,13 +43,25 @@ hljs.registerLanguage('html', xmlHljs);
|
||||
hljs.registerLanguage('xml', xmlHljs);
|
||||
hljs.registerLanguage('yaml', yamlHljs);
|
||||
hljs.registerLanguage('toml', iniHljs);
|
||||
hljs.registerLanguage('bash', bashHljs);
|
||||
hljs.registerLanguage('markdown', markdownHljs);
|
||||
hljs.registerLanguage('css', cssHljs);
|
||||
hljs.registerLanguage('javascript', jsHljs);
|
||||
hljs.registerLanguage('go', goHljs);
|
||||
hljs.registerLanguage('csharp', csharpHljs);
|
||||
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage } = toRefs(props);
|
||||
const { value, language, followHeightOf, copyPlacement, copyMessage, downloadFileName, downloadButtonText } = toRefs(props);
|
||||
const { height } = followHeightOf.value ? useElementSize(followHeightOf) : { height: ref(null) };
|
||||
|
||||
const { copy, isJustCopied } = useCopy({ source: value, createToast: false });
|
||||
const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.value);
|
||||
|
||||
const valueBase64 = computed(() => Base64.encode(value.value));
|
||||
const { download } = useDownloadFileFromBase64(
|
||||
{
|
||||
source: valueBase64,
|
||||
filename: downloadFileName,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -49,11 +73,16 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
|
||||
:style="height ? `min-height: ${height - 40 /* card padding */ + 10 /* negative margin compensation */}px` : ''"
|
||||
>
|
||||
<n-config-provider :hljs="hljs">
|
||||
<n-code :code="value" :language="language" :trim="false" data-test-id="area-content" />
|
||||
<n-code :code="value" :language="language" :word-wrap="wordWrap" :trim="false" data-test-id="area-content" />
|
||||
</n-config-provider>
|
||||
</n-scrollbar>
|
||||
<div absolute right-10px top-10px>
|
||||
<c-tooltip v-if="value" :tooltip="tooltipText" position="left">
|
||||
<div
|
||||
v-if="value && copyPlacement !== 'none'"
|
||||
absolute right-10px
|
||||
:top-10px="copyPlacement === 'top-right' ? '' : 'no'"
|
||||
:bottom-10px="copyPlacement === 'bottom-right' ? '' : 'no'"
|
||||
>
|
||||
<c-tooltip v-if="value && copyPlacement !== 'outside'" :tooltip="tooltipText" position="left">
|
||||
<c-button circle important:h-10 important:w-10 @click="copy()">
|
||||
<n-icon size="22" :component="Copy" />
|
||||
</c-button>
|
||||
@@ -65,6 +94,11 @@ const tooltipText = computed(() => isJustCopied.value ? 'Copied!' : copyMessage.
|
||||
{{ tooltipText }}
|
||||
</c-button>
|
||||
</div>
|
||||
<div v-if="downloadFileName !== '' && value !== ''" mt-5 flex justify-center>
|
||||
<c-button secondary @click="download">
|
||||
{{ downloadButtonText }}
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { extension as getExtensionFromMimeType, extension as getMimeTypeFromExtension } from 'mime-types';
|
||||
import type { Ref } from 'vue';
|
||||
import type { MaybeRef, Ref } from 'vue';
|
||||
import _ from 'lodash';
|
||||
import { get } from '@vueuse/core';
|
||||
|
||||
export {
|
||||
getMimeTypeFromBase64,
|
||||
@@ -75,21 +76,11 @@ function downloadFromBase64({ sourceValue, filename, extension, fileMimeType }:
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64(
|
||||
{ source, filename, extension, fileMimeType }:
|
||||
{ source: Ref<string>; filename?: string; extension?: string; fileMimeType?: string }) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: source.value, filename, extension, fileMimeType });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64Refs(
|
||||
{ source, filename, extension }:
|
||||
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||
{ source: MaybeRef<string>; filename?: MaybeRef<string>; extension?: MaybeRef<string> }) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
||||
downloadFromBase64({ sourceValue: get(source), filename: get(filename), extension: get(extension) });
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -116,3 +107,13 @@ function previewImageFromBase64(base64String: string): HTMLImageElement {
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
function useDownloadFileFromBase64Refs(
|
||||
{ source, filename, extension }:
|
||||
{ source: Ref<string>; filename?: Ref<string>; extension?: Ref<string> }) {
|
||||
return {
|
||||
download() {
|
||||
downloadFromBase64({ sourceValue: source.value, filename: filename?.value, extension: extension?.value });
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import cards from '@younestouati/playing-cards-standard-deck';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { randIntFromInterval } from '@/utils/random';
|
||||
|
||||
const cardKeys = Object.keys(cards);
|
||||
type CardNames = keyof typeof cards;
|
||||
|
||||
const numberOfCards = useQueryParamOrStorage({ name: 'cards', storageName: 'card-picker:n', defaultValue: 5 });
|
||||
const [cardPicked, refreshCardPicked] = computedRefreshable(() =>
|
||||
Array.from({ length: numberOfCards.value },
|
||||
() => cardKeys[randIntFromInterval(0, 51)]));
|
||||
|
||||
const suitNames = {
|
||||
c: 'clubs (♣)',
|
||||
d: 'diamonds (♦)',
|
||||
h: 'hearts (♥)',
|
||||
s: 'spades (♠)',
|
||||
};
|
||||
const numberNames = {
|
||||
1: 'Ace',
|
||||
11: 'Jack',
|
||||
12: 'Queen',
|
||||
13: 'King',
|
||||
};
|
||||
function translateName(cardId: string) {
|
||||
const [, number, suit] = /(\d+)([cdhs])/.exec(cardId) || [];
|
||||
if (!number && !suit) {
|
||||
return cardId;
|
||||
}
|
||||
return `${numberNames[number as never] || number} of ${suitNames[suit as never] || suit}`;
|
||||
}
|
||||
|
||||
const cardPickedString = computed(() => cardPicked.value.map(translateName).join(', '));
|
||||
|
||||
const { copy } = useCopy({ source: cardPickedString, text: 'Cards Picked copied to the clipboard' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card>
|
||||
<div mb-2 flex justify-center>
|
||||
<img v-for="(card, index) in cardPicked" :key="index" style="width:90px" mr-1 :src="`data:image/svg+xml;base64,${cards[card as CardNames]}`">
|
||||
</div>
|
||||
<div mb-2>
|
||||
<textarea-copyable :value="cardPickedString" readonly mb-1 />
|
||||
</div>
|
||||
<div flex justify-center gap-3>
|
||||
<n-form-item label="Number of cards:" label-placement="left">
|
||||
<n-input-number v-model:value="numberOfCards" min="1" placeholder="Width of the text" />
|
||||
</n-form-item>
|
||||
</div>
|
||||
<div flex justify-center gap-3>
|
||||
<c-button @click="copy()">
|
||||
Copy deck
|
||||
</c-button>
|
||||
<c-button @click="refreshCardPicked">
|
||||
Refresh deck
|
||||
</c-button>
|
||||
</div>
|
||||
</c-card>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { PlayCard } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Card Picker',
|
||||
path: '/card-picker',
|
||||
description: 'Generate a deck of playing cards',
|
||||
keywords: ['card', 'deck', 'picker'],
|
||||
component: () => import('./card-picker.vue'),
|
||||
icon: PlayCard,
|
||||
createdAt: new Date('2025-02-09'),
|
||||
});
|
||||
@@ -1,46 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
import { randIntFromInterval } from '@/utils/random';
|
||||
|
||||
const [coinFlip, refreshCoinFlip] = computedRefreshable(() => ({
|
||||
coin: randIntFromInterval(0, 10) % 2 === 0 ? 'Heads' : 'Tails',
|
||||
dt: Date.now(),
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Transition name="bounce" mode="out-in">
|
||||
<div :key="coinFlip.dt" flex items-center justify-center>
|
||||
<div flex items-center justify-center rounded-full outline style="width: 5em; height: 5em">
|
||||
{{ coinFlip.coin }}
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
<div mt-4 flex justify-center>
|
||||
<c-button @click="refreshCoinFlip">
|
||||
Re flip
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.bounce-enter-active {
|
||||
animation: bounce-in 0.5s;
|
||||
}
|
||||
.bounce-leave-active {
|
||||
animation: bounce-in 0.5s reverse;
|
||||
}
|
||||
@keyframes bounce-in {
|
||||
0% {
|
||||
transform: scale(0);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.25);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Coin } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Coin Flipper',
|
||||
path: '/coin-flipper',
|
||||
description: 'Flip a coin',
|
||||
keywords: ['coin', 'flipper'],
|
||||
component: () => import('./coin-flipper.vue'),
|
||||
icon: Coin,
|
||||
createdAt: new Date('2025-02-09'),
|
||||
});
|
||||
@@ -1,66 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { DiceRoll } from '@dice-roller/rpg-dice-roller';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
import { useCopy } from '@/composable/copy';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
const dicesNotations = useQueryParamOrStorage({ name: 'dices', storageName: 'dice-roll:dices', defaultValue: '3d6' });
|
||||
const [diceRollResult, refreshDiceRollResult] = computedRefreshable(() => {
|
||||
try {
|
||||
return {
|
||||
error: '',
|
||||
roll: new DiceRoll(dicesNotations.value),
|
||||
};
|
||||
}
|
||||
catch (e: any) {
|
||||
return {
|
||||
error: e.toString(),
|
||||
roll: null,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const diceRollString = computed(() => diceRollResult.value.roll?.output || '');
|
||||
|
||||
const { copy } = useCopy({ source: diceRollString, text: 'Dice Roll copied to the clipboard' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<c-card>
|
||||
<c-input-text
|
||||
v-model:value="dicesNotations"
|
||||
label="Dice Roll Notations:" label-position="left"
|
||||
placeholder="Dice configuration"
|
||||
mb-2
|
||||
/>
|
||||
<n-p mb-2>
|
||||
For more information about Dice Notation, see <n-a href="https://dice-roller.github.io/documentation/guide/notation/" target="_blank">
|
||||
here
|
||||
</n-a>
|
||||
</n-p>
|
||||
|
||||
<c-alert v-if="diceRollResult.error" mb-2>
|
||||
{{ diceRollResult.error }}
|
||||
</c-alert>
|
||||
|
||||
<c-card v-if="!diceRollResult.error" title="Roll Result" mb-2>
|
||||
<input-copyable :value="diceRollResult.roll?.output" readonly mb-1 />
|
||||
<input-copyable :value="diceRollResult.roll?.total" label="Total" readonly placeholder="Dice Roll total:" label-position="left" mb-1 />
|
||||
</c-card>
|
||||
|
||||
<div mb-2 flex justify-center gap-3>
|
||||
<c-button @click="copy()">
|
||||
Copy roll result
|
||||
</c-button>
|
||||
<c-button @click="refreshDiceRollResult">
|
||||
Refresh roll
|
||||
</c-button>
|
||||
</div>
|
||||
|
||||
<c-card v-if="!diceRollResult.error" title="Dice Notation Stats" mb-2>
|
||||
<input-copyable :value="diceRollResult.roll?.minTotal" readonly label="Min Total:" label-position="left" mb-1 />
|
||||
<input-copyable :value="diceRollResult.roll?.maxTotal" readonly label="Max Total:" label-position="left" mb-1 />
|
||||
<input-copyable :value="diceRollResult.roll?.averageTotal" readonly label="Avg Total:" label-position="left" mb-1 />
|
||||
</c-card>
|
||||
</c-card>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Dice } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Dice Roller',
|
||||
path: '/dice-roller',
|
||||
description: 'RPG Dice Roller using Dice Notation',
|
||||
keywords: ['dice', 'rng', 'rpg', 'roller'],
|
||||
component: () => import('./dice-roller.vue'),
|
||||
icon: Dice,
|
||||
createdAt: new Date('2025-02-09'),
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test.describe('Tool - Fortune wheel', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/fortune-wheel');
|
||||
});
|
||||
|
||||
test('Has correct title', async ({ page }) => {
|
||||
await expect(page).toHaveTitle('Fortune wheel - IT Tools');
|
||||
});
|
||||
});
|
||||
@@ -1,85 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { FortuneWheel } from 'vue3-fortune-wheel';
|
||||
import type { Data, ImgParams } from 'vue3-fortune-wheel';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
import { computedRefreshable } from '@/composable/computedRefreshable';
|
||||
|
||||
const base = import.meta.env.BASE_URL;
|
||||
|
||||
const choices = useQueryParamOrStorage({ name: 'choices', storageName: 'fortune-wheel:chs', defaultValue: '' });
|
||||
const spinDuration = useQueryParamOrStorage({ name: 'duration', storageName: 'fortune-wheel:dur', defaultValue: 5 });
|
||||
|
||||
const colors = [
|
||||
{ bgColor: '#FF5733', color: '#FFFFFF' },
|
||||
{ bgColor: '#2E86C1', color: '#FFFFFF' },
|
||||
{ bgColor: '#28B463', color: '#FFFFFF' },
|
||||
{ bgColor: '#F1C40F', color: '#000000' },
|
||||
{ bgColor: '#8E44AD', color: '#FFFFFF' },
|
||||
{ bgColor: '#E74C3C', color: '#FFFFFF' },
|
||||
{ bgColor: '#1ABC9C', color: '#000000' },
|
||||
{ bgColor: '#34495E', color: '#FFFFFF' },
|
||||
{ bgColor: '#D35400', color: '#FFFFFF' },
|
||||
{ bgColor: '#2C3E50', color: '#FFFFFF' },
|
||||
];
|
||||
|
||||
const wheel = ref<InstanceType<typeof FortuneWheel> | null>(null);
|
||||
const data = computed(() => {
|
||||
return (choices.value || '').split('\n')
|
||||
.filter(s => s && s !== '')
|
||||
.map((choice, index) => ({ id: index + 1, value: choice, ...colors[index % colors.length] }));
|
||||
});
|
||||
|
||||
const logo: ImgParams = {
|
||||
src: `${base}logo.png`,
|
||||
width: 100,
|
||||
height: 100,
|
||||
};
|
||||
|
||||
const [randomGift, refreshGift] = computedRefreshable(() => {
|
||||
return Math.floor(Math.random() * data.value.length) + 1;
|
||||
});
|
||||
|
||||
const result = ref<Data>();
|
||||
function done(wheelResult: Data) {
|
||||
result.value = wheelResult;
|
||||
}
|
||||
|
||||
function restart() {
|
||||
refreshGift();
|
||||
wheel.value?.spin();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<n-form-item label="Spin Duration (seconds):" label-placement="left">
|
||||
<n-input-number v-model:value="spinDuration" :min="1" />
|
||||
</n-form-item>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="choices"
|
||||
label="Wheel choices (one per line):"
|
||||
placeholder="Wheel choices (one per line)"
|
||||
multiline
|
||||
rows="5"
|
||||
/>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<FortuneWheel
|
||||
ref="wheel"
|
||||
v-model="randomGift"
|
||||
middle-circle
|
||||
:img-params="logo"
|
||||
:anim-duration="spinDuration * 1000"
|
||||
:data="data"
|
||||
@done="done"
|
||||
/>
|
||||
|
||||
<div flex justify-center>
|
||||
<c-button @click="restart()">
|
||||
Restart
|
||||
</c-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
import { ArrowsShuffle } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'Fortune wheel',
|
||||
path: '/fortune-wheel',
|
||||
description: '',
|
||||
keywords: ['fortune', 'wheel'],
|
||||
component: () => import('./fortune-wheel.vue'),
|
||||
icon: ArrowsShuffle,
|
||||
createdAt: new Date('2025-02-24'),
|
||||
});
|
||||
+3
-13
@@ -2,10 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter';
|
||||
import { tool as base64StringConverter } from './base64-string-converter';
|
||||
import { tool as basicAuthGenerator } from './basic-auth-generator';
|
||||
import { tool as emailNormalizer } from './email-normalizer';
|
||||
import { tool as fortuneWheel } from './fortune-wheel';
|
||||
import { tool as cardPicker } from './card-picker';
|
||||
import { tool as coinFlipper } from './coin-flipper';
|
||||
import { tool as diceRoller } from './dice-roller';
|
||||
import { tool as jwtGenerator } from './jwt-generator';
|
||||
|
||||
import { tool as asciiTextDrawer } from './ascii-text-drawer';
|
||||
|
||||
@@ -134,6 +131,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
otpCodeGeneratorAndValidator,
|
||||
mimeTypes,
|
||||
jwtParser,
|
||||
jwtGenerator,
|
||||
keycodeInfo,
|
||||
slugifyString,
|
||||
htmlWysiwygEditor,
|
||||
@@ -172,15 +170,7 @@ export const toolsByCategory: ToolCategory[] = [
|
||||
},
|
||||
{
|
||||
name: 'Math',
|
||||
components: [
|
||||
mathEvaluator,
|
||||
etaCalculator,
|
||||
percentageCalculator,
|
||||
diceRoller,
|
||||
coinFlipper,
|
||||
cardPicker,
|
||||
fortuneWheel,
|
||||
],
|
||||
components: [mathEvaluator, etaCalculator, percentageCalculator],
|
||||
},
|
||||
{
|
||||
name: 'Measurement',
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Key } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: 'JWT Generator',
|
||||
path: '/jwt-generator',
|
||||
description: 'JWT Token generator and editor',
|
||||
keywords: [
|
||||
'jwt',
|
||||
'generator',
|
||||
'editor',
|
||||
'encode',
|
||||
'typ',
|
||||
'alg',
|
||||
'iss',
|
||||
'sub',
|
||||
'aud',
|
||||
'exp',
|
||||
'nbf',
|
||||
'iat',
|
||||
'jti',
|
||||
'json',
|
||||
'web',
|
||||
'token',
|
||||
],
|
||||
component: () => import('./jwt-generator.vue'),
|
||||
icon: Key,
|
||||
createdAt: new Date('2024-08-15'),
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
export const jwsAlgorithms = [
|
||||
{ alg: 'HS256', keyDesc: '256 bit (32 byte) secret', key: 'secret', verify: 'HMAC-SHA256' },
|
||||
{ alg: 'HS384', keyDesc: '384 bit (48 byte) secret', key: 'secret', verify: 'HMAC-SHA384' },
|
||||
{ alg: 'HS512', keyDesc: '512 bit (64 byte) secret', key: 'secret', verify: 'HMAC-SHA512' },
|
||||
{ alg: 'ES256', keyDesc: 'NIST P-256 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA256' },
|
||||
{ alg: 'ES256K', keyDesc: 'secp256k1 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA256(secp256k1)' },
|
||||
{ alg: 'ES384', keyDesc: 'NIST P-384 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA384' },
|
||||
{ alg: 'ES512', keyDesc: 'NIST P-521 elliptic curve key', key: 'keyspair', verify: 'ECDSA-SHA512' },
|
||||
{ alg: 'PS256', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-PSS-SHA256' },
|
||||
{ alg: 'PS384', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-PSS-SHA384' },
|
||||
{ alg: 'PS512', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-PSS-SHA512' },
|
||||
{ alg: 'RS256', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-SHA256' },
|
||||
{ alg: 'RS384', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-SHA384' },
|
||||
{ alg: 'RS512', keyDesc: 'RSA key of at least 2048 bit modulus length', key: 'keyspair', verify: 'RSA-SHA512' },
|
||||
];
|
||||
@@ -0,0 +1,187 @@
|
||||
<script setup lang="ts">
|
||||
import * as jose from 'jose';
|
||||
import { type KeyLike } from 'jose';
|
||||
import JSON5 from 'json5';
|
||||
import { jwsAlgorithms } from './jwt-generator.constants';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { useQueryParamOrStorage } from '@/composable/queryParams';
|
||||
|
||||
const payload = ref(`{
|
||||
"sub": "1234567890",
|
||||
"name": "John Doe",
|
||||
"iat": 1516239022
|
||||
}`);
|
||||
|
||||
const alg = useQueryParamOrStorage({ name: 'alg', storageName: 'jwt-gen:alg', defaultValue: 'HS512' });
|
||||
const algInfo = computed(() => jwsAlgorithms.find(a => a.alg === alg.value) || { alg: 'UNK', keyDesc: '', key: 'secret', verify: '' });
|
||||
const isSecret = computed(() => algInfo.value.key === 'secret');
|
||||
|
||||
const secret = ref('');
|
||||
|
||||
const publicKeyPEM = ref('');
|
||||
const publicKeyJWK = ref('');
|
||||
const privateKeyJWK = ref('');
|
||||
const privateKeyPEM = ref('');
|
||||
|
||||
watch(publicKeyPEM, async (newValue) => {
|
||||
try {
|
||||
publicKeyJWK.value = JSON.stringify(await jose.exportJWK(await jose.importSPKI(newValue, alg.value, { extractable: true })), null, 2);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}, { immediate: true });
|
||||
watch(privateKeyPEM, async (newValue) => {
|
||||
try {
|
||||
privateKeyJWK.value = JSON.stringify(await jose.exportJWK(await jose.importPKCS8(newValue, alg.value, { extractable: true })), null, 2);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}, { immediate: true });
|
||||
watch(publicKeyJWK, async (newValue) => {
|
||||
try {
|
||||
publicKeyPEM.value = await jose.exportSPKI(await jose.importJWK({ ...JSON.parse(newValue), ...{ ext: true } }, alg.value) as KeyLike);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}, { immediate: true });
|
||||
watch(privateKeyJWK, async (newValue) => {
|
||||
try {
|
||||
privateKeyPEM.value = await jose.exportPKCS8(await jose.importJWK({ ...JSON.parse(newValue), ...{ ext: true } }, alg.value) as KeyLike);
|
||||
}
|
||||
catch {
|
||||
}
|
||||
}, { immediate: true });
|
||||
|
||||
watchEffect(async () => {
|
||||
if (isSecret.value) {
|
||||
secret.value = 'your-secret';
|
||||
privateKeyJWK.value = '';
|
||||
publicKeyJWK.value = '';
|
||||
privateKeyPEM.value = '';
|
||||
publicKeyPEM.value = '';
|
||||
}
|
||||
else {
|
||||
const { publicKey, privateKey } = await jose.generateKeyPair(alg.value, { extractable: true });
|
||||
privateKeyJWK.value = JSON.stringify(await jose.exportJWK(privateKey), null, 2);
|
||||
publicKeyJWK.value = JSON.stringify(await jose.exportJWK(publicKey), null, 2);
|
||||
privateKeyPEM.value = await jose.exportPKCS8(privateKey);
|
||||
publicKeyPEM.value = await jose.exportSPKI(publicKey);
|
||||
}
|
||||
});
|
||||
|
||||
const header = computed(() => JSON.stringify({ alg: alg.value, typ: 'JWT' }, null, 2));
|
||||
const encodedJWT = computedAsync(async () => {
|
||||
const isSecretValue = isSecret.value;
|
||||
const secretValue = secret.value;
|
||||
const privateKeyValue = privateKeyJWK.value;
|
||||
const algValue = alg.value;
|
||||
const payloadValue = payload.value;
|
||||
try {
|
||||
let privateKeyOrSecret;
|
||||
if (isSecretValue) {
|
||||
privateKeyOrSecret = new TextEncoder().encode(secretValue);
|
||||
}
|
||||
else {
|
||||
privateKeyOrSecret = await jose.importJWK(JSON.parse(privateKeyValue), algValue);
|
||||
}
|
||||
return {
|
||||
token: await (new jose.SignJWT(JSON5.parse(payloadValue))
|
||||
.setProtectedHeader({ alg: algValue })
|
||||
.sign(privateKeyOrSecret)),
|
||||
error: '',
|
||||
};
|
||||
}
|
||||
catch (e: any) {
|
||||
return { error: e.toString(), token: '' };
|
||||
}
|
||||
});
|
||||
|
||||
const jsonInputValidation = useValidation({
|
||||
source: payload,
|
||||
rules: [
|
||||
{
|
||||
message: 'Invalid JSON string',
|
||||
validator: value => JSON5.parse(value),
|
||||
},
|
||||
],
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<c-select
|
||||
v-model:value="alg"
|
||||
:options="jwsAlgorithms.map(a => ({ value: a.alg, label: `${a.alg}: ${a.verify}` }))"
|
||||
placeholder="Algorithms"
|
||||
mb-2
|
||||
/>
|
||||
<n-form-item label="Description:" label-placement="left" mb-2>
|
||||
{{ algInfo.alg }}: {{ algInfo.keyDesc }} (verify with {{ algInfo.verify }})
|
||||
</n-form-item>
|
||||
|
||||
<c-card title="Token Content" mb-2>
|
||||
<n-form-item label="Header:">
|
||||
<textarea-copyable :value="header" language="json" />
|
||||
</n-form-item>
|
||||
|
||||
<c-input-text
|
||||
v-model:value="payload"
|
||||
label="Payload:"
|
||||
multiline
|
||||
rows="5"
|
||||
autosize
|
||||
placeholder="JSON payload"
|
||||
:validation="jsonInputValidation"
|
||||
/>
|
||||
</c-card>
|
||||
|
||||
<c-card :title="isSecret ? 'Token Secret' : 'Token Keys'" mb-2>
|
||||
<c-input-text v-if="isSecret" v-model:value="secret" />
|
||||
|
||||
<div v-if="!isSecret">
|
||||
<n-form-item label="Public Key (PEM):">
|
||||
<c-input-text
|
||||
v-model:value="publicKeyPEM"
|
||||
multiline
|
||||
rows="5"
|
||||
autosize
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="Private Key (PEM):">
|
||||
<c-input-text
|
||||
v-model:value="privateKeyPEM"
|
||||
multiline
|
||||
rows="5"
|
||||
autosize
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<n-divider />
|
||||
|
||||
<n-form-item label="Public Key (JWK):">
|
||||
<c-input-text
|
||||
v-model:value="publicKeyJWK"
|
||||
multiline
|
||||
rows="5"
|
||||
autosize
|
||||
/>
|
||||
</n-form-item>
|
||||
<n-form-item label="Private Key (JWK):">
|
||||
<c-input-text
|
||||
v-model:value="privateKeyJWK"
|
||||
multiline
|
||||
rows="5"
|
||||
autosize
|
||||
/>
|
||||
</n-form-item>
|
||||
</div>
|
||||
</c-card>
|
||||
|
||||
<c-card v-if="encodedJWT" title="Generated JWT Token:" mb-2>
|
||||
<textarea-copyable v-if="encodedJWT.token" :value="encodedJWT.token" word-wrap />
|
||||
<c-alert v-if="encodedJWT.error">
|
||||
{{ encodedJWT.error }}
|
||||
</c-alert>
|
||||
</c-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Key } from '@vicons/tabler';
|
||||
import { defineTool } from '../tool';
|
||||
import { translate } from '@/plugins/i18n.plugin';
|
||||
|
||||
export const tool = defineTool({
|
||||
name: translate('tools.jwt-parser.title'),
|
||||
name: 'JWT parser',
|
||||
path: '/jwt-parser',
|
||||
description: translate('tools.jwt-parser.description'),
|
||||
description: 'Parse and decode your JSON Web Token (jwt) and display its content.',
|
||||
keywords: [
|
||||
'jwt',
|
||||
'parser',
|
||||
|
||||
@@ -2,7 +2,11 @@ import jwtDecode, { type JwtHeader, type JwtPayload } from 'jwt-decode';
|
||||
import _ from 'lodash';
|
||||
import { ALGORITHM_DESCRIPTIONS, CLAIM_DESCRIPTIONS } from './jwt-parser.constants';
|
||||
|
||||
export { decodeJwt };
|
||||
export { decodeJwt, getJwtAlgorithm };
|
||||
|
||||
function getJwtAlgorithm({ jwt }: { jwt: string }) {
|
||||
return jwtDecode<JwtHeader>(jwt, { header: true }).alg;
|
||||
}
|
||||
|
||||
function decodeJwt({ jwt }: { jwt: string }) {
|
||||
const rawHeader = jwtDecode<JwtHeader>(jwt, { header: true });
|
||||
@@ -19,7 +23,7 @@ function decodeJwt({ jwt }: { jwt: string }) {
|
||||
|
||||
function parseClaims({ claim, value }: { claim: string; value: unknown }) {
|
||||
const claimDescription = CLAIM_DESCRIPTIONS[claim];
|
||||
const formattedValue = _.isPlainObject(value) || _.isArray(value) ? JSON.stringify(value, null, 3) : _.toString(value);
|
||||
const formattedValue = _.isPlainObject(value) ? JSON.stringify(value, null, 3) : _.toString(value);
|
||||
const friendlyValue = getFriendlyValue({ claim, value });
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { decodeJwt } from './jwt-parser.service';
|
||||
import * as jose from 'jose';
|
||||
import JSON5 from 'json5';
|
||||
import { decodeJwt, getJwtAlgorithm } from './jwt-parser.service';
|
||||
import { useValidation } from '@/composable/validation';
|
||||
import { isNotThrowing } from '@/utils/boolean';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
@@ -26,6 +28,41 @@ const validation = useValidation({
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const secretOrPublicKey = ref('');
|
||||
const signatureVerification = computedAsync(async () => {
|
||||
const secretOrPublicKeyValue = secretOrPublicKey.value?.trim();
|
||||
if (!secretOrPublicKeyValue) {
|
||||
return { error: 'No secret or key provided' };
|
||||
}
|
||||
const jwt = rawJwt.value?.trim();
|
||||
if (!jwt) {
|
||||
return { error: 'No JWT token provided' };
|
||||
}
|
||||
try {
|
||||
const alg = getJwtAlgorithm({ jwt }) || 'unk';
|
||||
|
||||
if (secretOrPublicKeyValue.startsWith('{')) {
|
||||
const jwk = JSON5.parse(secretOrPublicKeyValue);
|
||||
const publicKey = await jose.importJWK(jwk, alg);
|
||||
|
||||
await jose.jwtVerify(jwt, publicKey);
|
||||
}
|
||||
else if (secretOrPublicKeyValue.includes('-----BEGIN PUBLIC KEY-----')) {
|
||||
const publicKey = await jose.importSPKI(secretOrPublicKeyValue, alg);
|
||||
await jose.jwtVerify(jwt, publicKey);
|
||||
}
|
||||
else {
|
||||
const secret = new TextEncoder().encode(secretOrPublicKeyValue);
|
||||
await jose.jwtVerify(jwt, secret);
|
||||
}
|
||||
|
||||
return { error: '' };
|
||||
}
|
||||
catch (e: any) {
|
||||
return { error: `Key or secret or verification error: ${e.toString()}` };
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -39,7 +76,7 @@ const validation = useValidation({
|
||||
{{ section.title }}
|
||||
</th>
|
||||
<tr v-for="{ claim, claimDescription, friendlyValue, value } in decodedJWT[section.key]" :key="claim + value">
|
||||
<td class="claims" style="vertical-align: top;">
|
||||
<td class="claims">
|
||||
<span font-bold>
|
||||
{{ claim }}
|
||||
</span>
|
||||
@@ -47,7 +84,7 @@ const validation = useValidation({
|
||||
({{ claimDescription }})
|
||||
</span>
|
||||
</td>
|
||||
<td style="word-wrap: break-word;word-break: break-all;">
|
||||
<td>
|
||||
<span>{{ value }}</span>
|
||||
<span v-if="friendlyValue" ml-2 op-70>
|
||||
({{ friendlyValue }})
|
||||
@@ -57,6 +94,21 @@ const validation = useValidation({
|
||||
</template>
|
||||
</tbody>
|
||||
</n-table>
|
||||
|
||||
<c-card title="Signature Validation">
|
||||
<c-input-text
|
||||
v-model:value="secretOrPublicKey" label="Secret or Public Key (SPKI or JWK)"
|
||||
placeholder="Put your secret or Public key here..." rows="5" multiline raw-text autofocus mb-3
|
||||
/>
|
||||
|
||||
<c-alert v-if="signatureVerification?.error">
|
||||
{{ signatureVerification.error }}
|
||||
</c-alert>
|
||||
|
||||
<n-alert v-if="!signatureVerification?.error" type="success">
|
||||
Signature verified
|
||||
</n-alert>
|
||||
</c-card>
|
||||
</c-card>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in new issue
Block a user