Compare commits

..
Author SHA1 Message Date
ShareVB 42f39bfa6e chore: fix strange corepack message
Fix corepack claiming strange thing : UsageError: This project is configured to use yarn because /home/runner/work/it-tools/it-tools/package.json has a "packageManager" field
2024-06-16 21:41:55 +02:00
ShareVB 130183cb36 fix: final modifs 2024-06-16 21:39:55 +02:00
sharevb 43922ae5f9 feat(TextAreaCopyable): word wrap 2024-06-16 18:03:46 +02:00
sharevb c906f11745 feat(New tool): API Tester
Fix #837
2024-06-16 12:45:14 +02:00
11 changed files with 183 additions and 258 deletions

No files matched your search

+4 -6
View File
@@ -11,6 +11,7 @@ declare module '@vue/runtime-core' {
export interface GlobalComponents {
'404.page': typeof import('./src/pages/404.page.vue')['default']
About: typeof import('./src/pages/About.vue')['default']
ApiTester: typeof import('./src/tools/api-tester/api-tester.vue')['default']
App: typeof import('./src/App.vue')['default']
AsciiTextDrawer: typeof import('./src/tools/ascii-text-drawer/ascii-text-drawer.vue')['default']
'Base.layout': typeof import('./src/layouts/base.layout.vue')['default']
@@ -55,7 +56,6 @@ declare module '@vue/runtime-core' {
ColoredCard: typeof import('./src/components/ColoredCard.vue')['default']
CommandPalette: typeof import('./src/modules/command-palette/command-palette.vue')['default']
CommandPaletteOption: typeof import('./src/modules/command-palette/components/command-palette-option.vue')['default']
CrcCalculator: typeof import('./src/tools/crc-calculator/crc-calculator.vue')['default']
CrontabGenerator: typeof import('./src/tools/crontab-generator/crontab-generator.vue')['default']
CSelect: typeof import('./src/ui/c-select/c-select.vue')['default']
'CSelect.demo': typeof import('./src/ui/c-select/c-select.demo.vue')['default']
@@ -128,10 +128,12 @@ declare module '@vue/runtime-core' {
MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default']
MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default']
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']
NDynamicInput: typeof import('naive-ui')['NDynamicInput']
NEllipsis: typeof import('naive-ui')['NEllipsis']
NFormItem: typeof import('naive-ui')['NFormItem']
NGi: typeof import('naive-ui')['NGi']
@@ -139,18 +141,14 @@ declare module '@vue/runtime-core' {
NH1: typeof import('naive-ui')['NH1']
NH3: typeof import('naive-ui')['NH3']
NIcon: typeof import('naive-ui')['NIcon']
NInput: typeof import('naive-ui')['NInput']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NLabel: typeof import('naive-ui')['NLabel']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NScrollbar: typeof import('naive-ui')['NScrollbar']
NSlider: typeof import('naive-ui')['NSlider']
NSpin: typeof import('naive-ui')['NSpin']
NStatistic: typeof import('naive-ui')['NStatistic']
NSwitch: typeof import('naive-ui')['NSwitch']
NTable: typeof import('naive-ui')['NTable']
NTag: typeof import('naive-ui')['NTag']
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']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
-1
View File
@@ -52,7 +52,6 @@
"colord": "^2.9.3",
"composerize-ts": "^0.6.2",
"country-code-lookup": "^0.1.0",
"crc": "^4.3.2",
"cron-validator": "^1.3.1",
"cronstrue": "^2.26.0",
"crypto-js": "^4.1.1",
+6 -20
View File
@@ -56,9 +56,6 @@ dependencies:
country-code-lookup:
specifier: ^0.1.0
version: 0.1.0
crc:
specifier: ^4.3.2
version: 4.3.2
cron-validator:
specifier: ^1.3.1
version: 1.3.1
@@ -3357,7 +3354,7 @@ packages:
dependencies:
'@unhead/dom': 0.5.1
'@unhead/schema': 0.5.1
'@vueuse/shared': 10.10.0(vue@3.3.4)
'@vueuse/shared': 10.8.0(vue@3.3.4)
unhead: 0.5.1
vue: 3.3.4
transitivePeerDependencies:
@@ -3990,17 +3987,17 @@ packages:
- vue
dev: false
/@vueuse/shared@10.10.0(vue@3.3.4):
resolution: {integrity: sha512-2aW33Ac0Uk0U+9yo3Ypg9s5KcR42cuehRWl7vnUHadQyFvCktseyxxEPBi1Eiq4D2yBGACOnqLZpx1eMc7g5Og==}
/@vueuse/shared@10.3.0(vue@3.3.4):
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
dependencies:
vue-demi: 0.14.7(vue@3.3.4)
vue-demi: 0.14.5(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
dev: false
/@vueuse/shared@10.3.0(vue@3.3.4):
resolution: {integrity: sha512-kGqCTEuFPMK4+fNWy6dUOiYmxGcUbtznMwBZLC1PubidF4VZY05B+Oht7Jh7/6x4VOWGpvu3R37WHi81cKpiqg==}
/@vueuse/shared@10.8.0(vue@3.3.4):
resolution: {integrity: sha512-dUdy6zwHhULGxmr9YUg8e+EnB39gcM4Fe2oKBSrh3cOsV30JcMPtsyuspgFCUo5xxFNaeMf/W2yyKfST7Bg8oQ==}
dependencies:
vue-demi: 0.14.7(vue@3.3.4)
transitivePeerDependencies:
@@ -4623,16 +4620,6 @@ packages:
resolution: {integrity: sha512-IOI66HEG+8bXfWPy+sTzuN7161vmDZOHg1wgIPFf3WfD73FeLajnn6C+fnxOIa9RL1WRBDMXQQWW/FOaOYaQ3w==}
dev: false
/crc@4.3.2:
resolution: {integrity: sha512-uGDHf4KLLh2zsHa8D8hIQ1H/HtFQhyHrc0uhHBcoKGol/Xnb+MPYfUMw7cvON6ze/GUESTudKayDcJC5HnJv1A==}
engines: {node: '>=12'}
peerDependencies:
buffer: '>=6.0.3'
peerDependenciesMeta:
buffer:
optional: true
dev: false
/crelt@1.0.6:
resolution: {integrity: sha512-VQ2MBenTq1fWZUH9DJNGti7kKv6EeAuYr3cLwxUWhIu1baTaXh4Ib5W2CqHVqib4/MqbYGJqiL3Zb8GJZr3l4g==}
dev: false
@@ -9462,7 +9449,6 @@ packages:
/workbox-google-analytics@7.0.0:
resolution: {integrity: sha512-MEYM1JTn/qiC3DbpvP2BVhyIH+dV/5BjHk756u9VbwuAhu0QHyKscTnisQuz21lfRpOwiS9z4XdqeVAKol0bzg==}
deprecated: It is not compatible with newer versions of GA starting with v4, as long as you are using GAv3 it should be ok, but the package is not longer being maintained
dependencies:
workbox-background-sync: 7.0.0
workbox-core: 7.0.0
+2 -1
View File
@@ -16,6 +16,7 @@ const props = withDefaults(
language?: string
copyPlacement?: 'top-right' | 'bottom-right' | 'outside' | 'none'
copyMessage?: string
wordWrap?: boolean
}>(),
{
followHeightOf: null,
@@ -47,7 +48,7 @@ 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>
-21
View File
@@ -1,21 +0,0 @@
import _ from 'lodash';
function useDebouncedRef<T>(initialValue: T, delay: number, immediate: boolean = false) {
const state = ref(initialValue);
const debouncedRef = customRef((track, trigger) => ({
get() {
track();
return state.value;
},
set: _.debounce(
(value) => {
state.value = value;
trigger();
},
delay,
{ leading: immediate },
),
}));
return debouncedRef;
}
export default useDebouncedRef;
+155
View File
@@ -0,0 +1,155 @@
<script setup lang="ts">
import { useQueryParamOrStorage } from '@/composable/queryParams';
import TextareaCopyable from '@/components/TextareaCopyable.vue';
interface KeyValuePair {
key: string
value?: string
}
const baseUrl = useQueryParamOrStorage({ name: 'url', storageName: 'api-tester:url', defaultValue: '' });
const method = useQueryParamOrStorage({ name: 'method', storageName: 'api-tester:m', defaultValue: 'POST' });
const queryParams = useQueryParamOrStorage<KeyValuePair[]>({ name: 'params', storageName: 'api-tester:params', defaultValue: [] });
const headers = useQueryParamOrStorage<KeyValuePair[]>({ name: 'headers', storageName: 'api-tester:headers', defaultValue: [] });
const contentType = useQueryParamOrStorage({ name: 'ct', storageName: 'api-tester:ct', defaultValue: 'application/json' });
const body = useQueryParamOrStorage({ name: 'body', storageName: 'api-tester:body', defaultValue: '' });
const noCORS = ref(false);
const apiCallResult = ref();
const inprogress = ref(false);
async function callAPI() {
const url = new URL(baseUrl.value);
for (const kv of queryParams.value) {
if (!kv.key) {
continue;
}
url.searchParams.append(kv.key, kv.value || '');
}
const queryHeaders = [] as [string, string][];
for (const kv of headers.value) {
if (!kv.key) {
continue;
}
queryHeaders.push([kv.key, kv.value || '']);
}
queryHeaders.push(['Content-Type', contentType.value || '']);
try {
const response = await fetch(url, {
method: method.value,
headers: queryHeaders,
body: (method.value === 'GET' || method.value === 'HEAD') ? null : body.value,
mode: noCORS.value ? 'no-cors' : 'cors',
});
let responseText = await response.text();
try {
responseText = JSON.stringify(JSON.parse(responseText), null, 2);
}
catch (_) {
}
apiCallResult.value = {
code: response.status,
error: '',
result: responseText,
};
}
catch (err: any) {
apiCallResult.value = {
code: -1,
error: err.toString(),
result: null,
};
}
}
function emptyKeyPair() {
return {
key: '',
value: '',
};
}
</script>
<template>
<div>
<c-card title="API Calling">
<c-input-text
v-model:value="baseUrl"
label="Base API Url"
placeholder="Base API Url"
mb-2
/>
<c-select
v-model:value="method"
label="HTTP Method:"
:options="['GET', 'POST', 'PUT', 'DELETE', 'PATCH']"
mb-2
/>
<c-card title="Headers" mb-2>
<n-dynamic-input v-model:value="headers" :on-create="emptyKeyPair">
<template #create-button-default>
Add a new HTTP Header
</template>
<template #default="{ value }">
<div v-if="value" w-100 flex justify-center gap-2>
<c-input-text v-model:value="value.key" placeholder="Header Name" type="text" />
<c-input-text v-model:value="value.value" placeholder="Value" type="text" />
</div>
</template>
</n-dynamic-input>
<c-select
v-model:value="contentType"
label="Content-Type:"
:options="['application/json', 'text/plain']"
mt-2
/>
</c-card>
<c-card title="Query Parameters" mb-2>
<n-dynamic-input v-model:value="queryParams" :on-create="emptyKeyPair">
<template #create-button-default>
Add a new Query Parameter
</template>
<template #default="{ value }">
<div v-if="value" w-100 flex justify-center gap-2>
<c-input-text v-model:value="value.key" placeholder="Param Name" type="text" />
<c-input-text v-model:value="value.value" placeholder="Value" type="text" />
</div>
</template>
</n-dynamic-input>
</c-card>
<c-input-text
v-if="method !== 'GET' && method !== 'HEAD'"
v-model:value="body"
label="Body"
placeholder="HTTP Query body"
multiline
monospace
mb-2
/>
<n-checkbox v-model:checked="noCORS">
No CORS
</n-checkbox>
<div mt-5 flex justify-center>
<c-button secondary @click="callAPI">
Call API
</c-button>
</div>
</c-card>
<n-spin
v-if="inprogress"
size="small"
/>
<c-alert v-if="!inprogress && apiCallResult && apiCallResult.code !== 200" type="error" mt-12 title="Error while calling API">
<p><strong>Status code = {{ apiCallResult.code }}</strong></p>
<TextareaCopyable :value="apiCallResult.error" copy-placement="none" />
</c-alert>
<c-card v-if="!inprogress && apiCallResult && apiCallResult.code === 200" mt-12 title="API Call result">
<TextareaCopyable :value="apiCallResult.result" word-wrap />
</c-card>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { World } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'API Tester',
path: '/api-tester',
description: 'HTTP API Tester',
keywords: ['api', 'http', 'call', 'tester'],
component: () => import('./api-tester.vue'),
icon: World,
createdAt: new Date('2024-05-11'),
});
-168
View File
@@ -1,168 +0,0 @@
<script setup lang="ts">
import type { lib } from 'crypto-js';
import { enc } from 'crypto-js';
import crc from 'crc';
import InputCopyable from '../../components/InputCopyable.vue';
import { convertHexToBin } from '../hash-text/hash-text.service';
import { useQueryParamOrStorage } from '@/composable/queryParams';
import { withDefaultOnError } from '@/utils/defaults';
const status = ref<'idle' | 'done' | 'error' | 'processing'>('idle');
const text = ref('');
const file = ref<File | null>(null);
const defaultCRCValues = {
crc1: '',
crc8: '',
crc81wire: '',
crc8dvbs2: '',
crc16: '',
crc16ccitt: '',
crc16modbus: '',
crc16kermit: '',
crc16xmodem: '',
crc24: '',
crc32: '',
crc32mpeg: '',
crcjam: '',
};
type AlgoNames = keyof typeof defaultCRCValues;
function getCRCs(content: Uint8Array | string) {
return {
crc1: crc.crc1(content).toString(16),
crc8: crc.crc8(content).toString(16),
crc81wire: crc.crc81wire(content).toString(16),
crc8dvbs2: crc.crc8dvbs2(content).toString(16),
crc16: crc.crc16(content).toString(16),
crc16ccitt: crc.crc16ccitt(content).toString(16),
crc16modbus: crc.crc16modbus(content).toString(16),
crc16kermit: crc.crc16kermit(content).toString(16),
crc16xmodem: crc.crc16xmodem(content).toString(16),
crc24: crc.crc24(content).toString(16),
crc32: crc.crc32(content).toString(16),
crc32mpeg: crc.crc32mpeg2(content).toString(16),
crcjam: crc.crcjam(content).toString(16),
};
}
const hashes = ref(defaultCRCValues);
async function onUpload(uploadedFile: File) {
status.value = 'processing';
file.value = uploadedFile;
const buffer = await uploadedFile.arrayBuffer();
text.value = '';
try {
hashes.value = getCRCs(new Uint8Array(buffer));
status.value = 'done';
}
catch (e) {
status.value = 'error';
}
}
const algoWasmNames = Object.keys(defaultCRCValues) as AlgoNames[];
type Encoding = keyof typeof enc | 'Bin';
const encoding = useQueryParamOrStorage<Encoding>({ defaultValue: 'Hex', storageName: 'hash-text:encoding', name: 'encoding' });
function formatWithEncoding(words: lib.WordArray, encoding: Encoding) {
if (encoding === 'Bin') {
return convertHexToBin(words.toString(enc.Hex));
}
return words.toString(enc[encoding]);
}
const CRCValues = computed(() => withDefaultOnError(() => {
const encodingValue = encoding.value;
const hashesValue = hashes.value;
const ret = defaultCRCValues;
for (const algo of algoWasmNames) {
ret[algo] = formatWithEncoding(enc.Hex.parse(hashesValue[algo]), encodingValue);
}
return ret;
}, defaultCRCValues));
watch(text,
(_, newValue) => {
if (newValue === '') {
return;
}
file.value = null;
hashes.value = getCRCs(newValue);
status.value = 'done';
},
);
</script>
<template>
<div>
<c-card>
<c-file-upload
title="Drag and drop a file here, or click to select a file"
@file-upload="onUpload"
/>
<p>OR</p>
<c-input-text
v-model:value="text"
multiline raw-text
placeholder="Paste string to CRC..." rows="3"
autosize autofocus label="Your text to CRC:"
/>
<n-divider />
<c-select
v-model:value="encoding"
mb-4
label="Digest encoding"
:options="[
{
label: 'Binary (base 2)',
value: 'Bin',
},
{
label: 'Hexadecimal (base 16)',
value: 'Hex',
},
{
label: 'Base64 (base 64)',
value: 'Base64',
},
{
label: 'Base64url (base 64 with url safe chars)',
value: 'Base64url',
},
]"
/>
</c-card>
<div mt-3 flex justify-center>
<c-alert v-if="status === 'error'" type="error">
An error occured hashing file.
</c-alert>
<n-spin
v-if="status === 'processing'"
size="small"
/>
</div>
<c-card v-if="status === 'done'" :title="file === null ? 'CRC of text' : `CRC of ${file?.name}`">
<div v-for="algo in algoWasmNames" :key="algo" style="margin: 5px 0">
<n-input-group>
<n-input-group-label style="flex: 0 0 120px">
{{ algo.toUpperCase() }}
</n-input-group-label>
<InputCopyable :value="CRCValues[algo]" readonly />
</n-input-group>
</div>
</c-card>
</div>
</template>
-24
View File
@@ -1,24 +0,0 @@
import { EyeOff } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'CRC calculator',
path: '/crc-calculator',
description: 'Compute text or file CRC (CRC1, CRC8, CRC8 1-Wire, CRC8 DVB-S2, CRC16, CRC16 CCITT, CRC16 Modbus, CRC16 Kermit, CRC16 XModem, CRC24, CRC32, CRC32 MPEG-2, CRCJAM)',
keywords: ['crc', 'checksum', 'crc1',
'crc8',
'crc8 1-wire',
'crc8 dvb-s2',
'crc16',
'crc16 ccitt',
'crc16 modbus',
'crc16 kermit',
'crc16 xmodem',
'crc24',
'crc32',
'crc32 mpeg-2',
'crcjam'],
component: () => import('./crc-calculator.vue'),
icon: EyeOff,
createdAt: new Date('2024-05-11'),
});
+1 -2
View File
@@ -4,7 +4,6 @@ import emojiKeywords from 'emojilib';
import _ from 'lodash';
import type { EmojiInfo } from './emoji.types';
import { useFuzzySearch } from '@/composable/fuzzySearch';
import useDebouncedRef from '@/composable/debouncedref';
const escapeUnicode = ({ emoji }: { emoji: string }) => emoji.split('').map(unit => `\\u${unit.charCodeAt(0).toString(16).padStart(4, '0')}`).join('');
const getEmojiCodePoints = ({ emoji }: { emoji: string }) => emoji.codePointAt(0) ? `0x${emoji.codePointAt(0)?.toString(16)}` : undefined;
@@ -24,7 +23,7 @@ const emojisGroups: { emojiInfos: EmojiInfo[]; group: string }[] = _
.map((emojiInfos, group) => ({ group, emojiInfos }))
.value();
const searchQuery = useDebouncedRef('', 500);
const searchQuery = ref('');
const { searchResult } = useFuzzySearch({
search: searchQuery,
+3 -15
View File
@@ -5,8 +5,8 @@ import { tool as basicAuthGenerator } from './basic-auth-generator';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
import { tool as textToUnicode } from './text-to-unicode';
import { tool as crcCalculator } from './crc-calculator';
import { tool as safelinkDecoder } from './safelink-decoder';
import { tool as apiTester } from './api-tester';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -86,20 +86,7 @@ import { tool as yamlViewer } from './yaml-viewer';
export const toolsByCategory: ToolCategory[] = [
{
name: 'Crypto',
components: [
tokenGenerator,
hashText,
crcCalculator,
bcrypt,
uuidGenerator,
ulidGenerator,
cypher,
bip39,
hmacGenerator,
rsaKeyPairGenerator,
passwordStrengthAnalyser,
pdfSignatureChecker,
],
components: [tokenGenerator, hashText, bcrypt, uuidGenerator, ulidGenerator, cypher, bip39, hmacGenerator, rsaKeyPairGenerator, passwordStrengthAnalyser, pdfSignatureChecker],
},
{
name: 'Converter',
@@ -142,6 +129,7 @@ export const toolsByCategory: ToolCategory[] = [
httpStatusCodes,
jsonDiff,
safelinkDecoder,
apiTester,
],
},
{