Compare commits

..
Author SHA1 Message Date
ShareVB 0d7e6ea82e Merge remote-tracking branch 'origin/main' into feat/luhn-checker 2024-10-06 22:19:29 +02:00
sharevb 98c50f0f2a feat(new tool): Luhn Checker
Check kuhn identifiers
2024-10-06 17:24:37 +02:00
9 changed files with 77 additions and 176 deletions

No files matched your search

+2 -5
View File
@@ -107,7 +107,6 @@ declare module '@vue/runtime-core' {
Ipv4RangeExpander: typeof import('./src/tools/ipv4-range-expander/ipv4-range-expander.vue')['default']
Ipv4SubnetCalculator: typeof import('./src/tools/ipv4-subnet-calculator/ipv4-subnet-calculator.vue')['default']
Ipv6UlaGenerator: typeof import('./src/tools/ipv6-ula-generator/ipv6-ula-generator.vue')['default']
Iso3166Searcher: typeof import('./src/tools/iso-3166-searcher/iso-3166-searcher.vue')['default']
JsonDiff: typeof import('./src/tools/json-diff/json-diff.vue')['default']
JsonMinify: typeof import('./src/tools/json-minify/json-minify.vue')['default']
JsonToCsv: typeof import('./src/tools/json-to-csv/json-to-csv.vue')['default']
@@ -120,6 +119,7 @@ declare module '@vue/runtime-core' {
ListConverter: typeof import('./src/tools/list-converter/list-converter.vue')['default']
LocaleSelector: typeof import('./src/modules/i18n/components/locale-selector.vue')['default']
LoremIpsumGenerator: typeof import('./src/tools/lorem-ipsum-generator/lorem-ipsum-generator.vue')['default']
LuhnValidator: typeof import('./src/tools/luhn-validator/luhn-validator.vue')['default']
MacAddressGenerator: typeof import('./src/tools/mac-address-generator/mac-address-generator.vue')['default']
MacAddressLookup: typeof import('./src/tools/mac-address-lookup/mac-address-lookup.vue')['default']
MarkdownToHtml: typeof import('./src/tools/markdown-to-html/markdown-to-html.vue')['default']
@@ -130,9 +130,8 @@ 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']
NCollapseTransition: typeof import('naive-ui')['NCollapseTransition']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDivider: typeof import('naive-ui')['NDivider']
@@ -143,8 +142,6 @@ declare module '@vue/runtime-core' {
NLayout: typeof import('naive-ui')['NLayout']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
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']
PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default']
+1 -2
View File
@@ -54,7 +54,6 @@
"change-case": "^4.1.2",
"colord": "^2.9.3",
"composerize-ts": "^0.6.2",
"countries-db": "^1.2.0",
"country-code-lookup": "^0.1.0",
"cron-validator": "^1.3.1",
"cronstrue": "^2.26.0",
@@ -69,12 +68,12 @@
"highlight.js": "^11.7.0",
"iarna-toml-esm": "^3.0.5",
"ibantools": "^4.3.3",
"iso-639-1": "^3.1.3",
"js-base64": "^3.7.6",
"json5": "^2.2.3",
"jwt-decode": "^3.1.2",
"libphonenumber-js": "^1.10.28",
"lodash": "^4.17.21",
"luhn-js": "^1.1.2",
"markdown-it": "^14.0.0",
"marked": "^10.0.0",
"mathjs": "^11.9.1",
+7 -15
View File
@@ -59,9 +59,6 @@ dependencies:
composerize-ts:
specifier: ^0.6.2
version: 0.6.2
countries-db:
specifier: ^1.2.0
version: 1.2.0
country-code-lookup:
specifier: ^0.1.0
version: 0.1.0
@@ -104,9 +101,6 @@ dependencies:
ibantools:
specifier: ^4.3.3
version: 4.3.3
iso-639-1:
specifier: ^3.1.3
version: 3.1.3
js-base64:
specifier: ^3.7.6
version: 3.7.7
@@ -122,6 +116,9 @@ dependencies:
lodash:
specifier: ^4.17.21
version: 4.17.21
luhn-js:
specifier: ^1.1.2
version: 1.1.2
markdown-it:
specifier: ^14.0.0
version: 14.1.0
@@ -4663,10 +4660,6 @@ packages:
browserslist: 4.22.1
dev: true
/countries-db@1.2.0:
resolution: {integrity: sha512-eZQgxVsNSRQ4yv9xQbgyR1psJBHDBhnhhU4OMXXUdrfbWW9gaiglKgueTq3ZWGuvxoR78g2ljVFsJmEptfNPmw==}
dev: false
/country-code-lookup@0.1.0:
resolution: {integrity: sha512-IOI66HEG+8bXfWPy+sTzuN7161vmDZOHg1wgIPFf3WfD73FeLajnn6C+fnxOIa9RL1WRBDMXQQWW/FOaOYaQ3w==}
dev: false
@@ -6502,11 +6495,6 @@ packages:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
dev: true
/iso-639-1@3.1.3:
resolution: {integrity: sha512-1jz0Wh9hyLMRwqEPchb/KZCiTqfFWtc9R3nm7GHPygBAKS8wdKJ3FH4lvLsri6UtAE5Kz5SnowtXZa//6bqMyw==}
engines: {node: '>=6.0'}
dev: false
/isobject@3.0.1:
resolution: {integrity: sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==}
engines: {node: '>=0.10.0'}
@@ -6832,6 +6820,10 @@ packages:
dependencies:
yallist: 4.0.0
/luhn-js@1.1.2:
resolution: {integrity: sha512-GdINoHY50s4Zkhvmt6Pss/8ZwVxIOLsMHuJCg6EDcT1heSt4hM2V+7aKCihemn8rI0n22+lxqomzgvWDzMyEuQ==}
dev: false
/magic-string@0.25.9:
resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==}
dependencies:
+6 -3
View File
@@ -2,6 +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 luhnValidator } from './luhn-validator';
import { tool as asciiTextDrawer } from './ascii-text-drawer';
@@ -12,7 +13,6 @@ import { tool as jsonToXml } from './json-to-xml';
import { tool as regexTester } from './regex-tester';
import { tool as regexMemo } from './regex-memo';
import { tool as markdownToHtml } from './markdown-to-html';
import { tool as iso3166Searcher } from './iso-3166-searcher';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -185,12 +185,15 @@ export const toolsByCategory: ToolCategory[] = [
textDiff,
numeronymGenerator,
asciiTextDrawer,
iso3166Searcher,
],
},
{
name: 'Data',
components: [phoneParserAndFormatter, ibanValidatorAndParser],
components: [
phoneParserAndFormatter,
ibanValidatorAndParser,
luhnValidator,
],
},
];
-35
View File
@@ -1,35 +0,0 @@
declare module 'countries-db'{
export interface CountryInfo {
id: string
name: string
officialName: string
emoji: string
emojiUnicode: string
iso2: string
iso3: string
isoNumeric: string
geonameId: number
continentId: string
population: number
elevation: number
areaSqKm: number
coordinates: {
latitude: number
longitude: number
},
timezones: Array<string>
domain: string
currencyCode: string
currencyName: string
postalCodeFormat: string
postalCodeRegex: string
phoneCode: string
neighborCountryIds: Array<string>
languages: Array<string>
locales: Array<string>
}
export function getAllCountries(): {[id:string]: CountryInfo};
export function getCountry(id: string, property: string): string | Array<string> | number;
export function getCountry(id: string): CountryInfo;
}
-12
View File
@@ -1,12 +0,0 @@
import { Flag } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'ISO 3166 Country Codes Searcher',
path: '/iso-3166-searcher',
description: 'Allow searching for Country Code (ISO 3166) and info',
keywords: ['iso', 'iso2', 'iso3', 'phone', 'currency', 'timezones', 'domain', 'lang', 'iso3166', 'country', 'ccltd', 'searcher'],
component: () => import('./iso-3166-searcher.vue'),
icon: Flag,
createdAt: new Date('2024-04-20'),
});
@@ -1,104 +0,0 @@
<script setup lang="ts">
import CountriesDB from 'countries-db';
import ISO6391 from 'iso-639-1';
import { useFuzzySearch } from '@/composable/fuzzySearch';
import useDebouncedRef from '@/composable/debouncedref';
const searchQuery = useDebouncedRef('', 500);
const countriesSearchData = Object.entries(CountriesDB.getAllCountries()).map(([_, info]) => {
return {
iso2: info.iso2,
iso3: info.iso3,
domain: info.domain,
name: `${info.name} ${info.officialName}`,
info,
};
});
const { searchResult } = useFuzzySearch({
search: searchQuery,
data: countriesSearchData,
options: {
keys: ['name', { name: 'iso3', weight: 3 }, { name: 'iso2', weight: 2 }, 'domain'],
threshold: 0.3,
isCaseSensitive: false,
useExtendedSearch: true,
},
});
function langToName(code: string) {
const name = ISO6391.getName(code);
if (!name) {
return code;
}
return `${code} (${name})`;
}
</script>
<template>
<div mx-auto max-w-2400px important:flex-1>
<div flex items-center gap-3>
<c-input-text
v-model:value="searchQuery"
placeholder="Search Countries by name, iso2, iso3..."
mx-auto max-w-600px
>
<template #prefix>
<icon-mdi-search mr-6px color-black op-70 dark:color-white />
</template>
</c-input-text>
</div>
<div v-if="searchQuery.trim().length > 0">
<div
v-if="searchResult.length === 0"
mt-4
text-20px
font-bold
>
No results
</div>
<div v-else>
<div mt-4 text-20px font-bold>
Search result
</div>
<n-table>
<thead>
<th>Iso2/Iso3</th>
<th>Name and Info</th>
</thead>
<tbody>
<tr v-for="(result, ix) in searchResult" :key="ix">
<td style="vertical-align: top">
<input-copyable :value="result.iso2" />
<input-copyable :value="result.iso3" />
</td>
<td>
<input-copyable label-width="150px" label="Name" label-position="left" :value="result.name" mb-1 />
<input-copyable label-width="150px" label="Official Name" label-position="left" :value="result.info.officialName" mb-1 />
<input-copyable label-width="150px" label="Domain" label-position="left" :value="result.info.domain" mb-1 />
<input-copyable label-width="150px" label="Emoji" label-position="left" :value="`${result.info.emoji} (${result.info.emojiUnicode})`" mb-1 />
<input-copyable label-width="150px" label="ISO Num" label-position="left" :value="result.info.isoNumeric" mb-1 />
<input-copyable label-width="150px" label="Continent" label-position="left" :value="result.info.continentId" mb-1 />
<input-copyable label-width="150px" label="Elevation (m)" label-position="left" :value="result.info.elevation" mb-1 />
<input-copyable label-width="150px" label="Population" label-position="left" :value="result.info.population" mb-1 />
<input-copyable label-width="150px" label="Area (km²)" label-position="left" :value="result.info.areaSqKm" mb-1 />
<input-copyable label-width="150px" label="Timezones" label-position="left" :value="result.info.timezones.join('\n')" mb-1 />
<input-copyable label-width="150px" label="Currency" label-position="left" :value="`${result.info.currencyCode} / ${result.info.currencyName}`" mb-1 />
<input-copyable label-width="150px" label="Postal Code" label-position="left" :value="`${result.info.postalCodeFormat} / ${result.info.postalCodeRegex}`" mb-1 />
<input-copyable label-width="150px" label="Phone Code" label-position="left" :value="result.info.phoneCode" mb-1 />
<input-copyable label-width="150px" label="Neighbor Countries" label-position="left" :value="result.info.neighborCountryIds.map(id => CountriesDB.getCountry(id, 'name')?.toString() || id).join(', ')" mb-1 />
<input-copyable label-width="150px" label="Languages" label-position="left" :value="result.info.languages.map(langToName).join(', ')" mb-1 />
<input-copyable label-width="150px" label="Locales" label-position="left" :value="result.info.locales.map(langToName).join(', ')" mb-1 />
<!-- //NOSONAR --><n-a :href="`https://www.openstreetmap.org/#map=5/${result.info.coordinates.latitude}/${result.info.coordinates.longitude}`" target="_blank">
&gt; See on OpenStreetMap
</n-a>
</td>
</tr>
</tbody>
</n-table>
</div>
</div>
</div>
</template>
+12
View File
@@ -0,0 +1,12 @@
import { Check } from '@vicons/tabler';
import { defineTool } from '../tool';
export const tool = defineTool({
name: 'Luhn Validator',
path: '/luhn-validator',
description: 'Check and generate key for identifier validated by a Luhn checknum',
keywords: ['luhn', 'credit-card', 'imei', 'identifier', 'validator'],
component: () => import('./luhn-validator.vue'),
icon: Check,
createdAt: new Date('2024-08-15'),
});
@@ -0,0 +1,49 @@
<script setup lang="ts">
import Luhn from 'luhn-js';
import type { CKeyValueListItems } from '@/ui/c-key-value-list/c-key-value-list.types';
const rawValue = ref('44540661970241257');
const cleanedValue = computed(() => rawValue.value.replace(/[^\d]/g, ''));
const isValid = computed(() => {
try {
return Luhn.isValid(cleanedValue.value);
}
catch (_) {
return false;
}
});
const luhnInfos = computed<CKeyValueListItems>(() => {
return [
{
label: 'Is valid ?',
value: isValid.value,
},
{
label: 'Luhn Key',
value: (isValid.value
? cleanedValue.value.slice(-1)
: Luhn.generate(cleanedValue.value).slice(-1)) || '',
},
{
label: 'Value with Luhn Key',
value: (isValid.value
? cleanedValue.value
: Luhn.generate(cleanedValue.value)) || '',
},
];
});
</script>
<template>
<div>
<c-input-text v-model:value="rawValue" placeholder="Enter a 'Luhn validated' value..." />
<n-alert v-if="!isValid" type="error">
Invalid Luhn Key.
<input-copyable label="Probably correct" label-position="left" :value="Luhn.generate(cleanedValue)" disabled="true" />
</n-alert>
<c-card v-if="luhnInfos.length > 0" mt-5 title="Infos">
<c-key-value-list :items="luhnInfos" />
</c-card>
</div>
</template>