diff --git a/components.d.ts b/components.d.ts index 4157a6ea..a9b2d776 100644 --- a/components.d.ts +++ b/components.d.ts @@ -179,6 +179,7 @@ declare module '@vue/runtime-core' { IconMdiEye: typeof import('~icons/mdi/eye')['default'] IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default'] IconMdiHeart: typeof import('~icons/mdi/heart')['default'] + IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] IconMdiSearch: typeof import('~icons/mdi/search')['default'] IconMdiTranslate: typeof import('~icons/mdi/translate')['default'] IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default'] @@ -289,12 +290,14 @@ declare module '@vue/runtime-core' { NH1: typeof import('naive-ui')['NH1'] NH3: typeof import('naive-ui')['NH3'] NIcon: typeof import('naive-ui')['NIcon'] + NImage: typeof import('naive-ui')['NImage'] NInputNumber: typeof import('naive-ui')['NInputNumber'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] NModal: typeof import('naive-ui')['NModal'] NP: typeof import('naive-ui')['NP'] + NProgress: typeof import('naive-ui')['NProgress'] NRate: typeof import('naive-ui')['NRate'] NScrollbar: typeof import('naive-ui')['NScrollbar'] NSlider: typeof import('naive-ui')['NSlider'] diff --git a/locales/de.yml b/locales/de.yml index 71c28ed3..24a853eb 100644 --- a/locales/de.yml +++ b/locales/de.yml @@ -453,7 +453,7 @@ tools: otp-generator: title: OTP-Code-Generator description: >- - Generiere und validiere zeitbasierte OTPs (Einmalpasswörter) für + Generiere und validiere zeitbasierte und ereignisgesteuertes OTPs (Einmalpasswörter) für Multi-Faktor-Authentifizierung. url-encoder: title: Kodieren/Decodieren von URL-formatierten Zeichenfolgen diff --git a/locales/en.yml b/locales/en.yml index 9c8d7e71..a5da8a86 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -437,7 +437,7 @@ tools: otp-generator: title: OTP code generator - description: Generate and validate time-based OTP (one time password) for multi-factor authentication. + description: Generate and validate time-based and event-based OTP (one time password) for multi-factor authentication. url-encoder: title: Encode/decode URL-formatted strings diff --git a/src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue b/src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue index 00db7e97..a2f94b9a 100644 --- a/src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue +++ b/src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue @@ -2,7 +2,7 @@ import { useTimestamp } from '@vueuse/core'; import { useThemeVars } from 'naive-ui'; import { useQRCode } from '../qr-code-generator/useQRCode'; -import { base32toHex, buildKeyUri, generateSecret, generateTOTP, getCounterFromTime } from './otp.service'; +import { base32toHex, buildKeyUri, generateHOTP, generateSecret, generateTOTP, getCounterFromTime } from './otp.service'; import TokenDisplay from './token-display.vue'; import { useStyleStore } from '@/stores/style.store'; import InputCopyable from '@/components/InputCopyable.vue'; @@ -24,6 +24,16 @@ function refreshSecret() { secret.value = generateSecret(); } +const counter = ref(0); + +const [hotpValues] = computedRefreshable( + () => + Object.fromEntries( + Array.from({ length: 10 }, (_, i) => [+counter.value + i, generateHOTP({ key: secret.value, counter: +counter.value + i })]), + ), + { throttle: 500 }, +); + const [tokens] = computedRefreshable( () => ({ previous: generateTOTP({ key: secret.value, now: now.value - 30000 }), @@ -73,23 +83,6 @@ const secretValidationRules = [ - -