diff --git a/modules/app/README.md b/modules/app/README.md index f5db2a2..0529770 100644 --- a/modules/app/README.md +++ b/modules/app/README.md @@ -1,6 +1,10 @@ -# Nuxt 3 Minimal Starter +[![Netlify Status](https://api.netlify.com/api/v1/badges/bcf66326-b808-4ffd-9018-fb24315fce5f/deploy-status)](https://app.netlify.com/sites/force-orange/deploys) -Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. +# Nuxt + +Look at the +[Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to +learn more. ## Setup @@ -72,4 +76,6 @@ yarn preview bun run preview ``` -Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. +Check out the +[deployment documentation](https://nuxt.com/docs/getting-started/deployment) for +more information. diff --git a/modules/app/components/FOHeader.vue b/modules/app/components/FOHeader.vue new file mode 100644 index 0000000..6bc7f8b --- /dev/null +++ b/modules/app/components/FOHeader.vue @@ -0,0 +1,42 @@ + + + \ No newline at end of file diff --git a/modules/app/components/PasswordStrength.vue b/modules/app/components/PasswordStrength.vue new file mode 100644 index 0000000..2c05201 --- /dev/null +++ b/modules/app/components/PasswordStrength.vue @@ -0,0 +1,41 @@ + + + \ No newline at end of file diff --git a/modules/app/composables/passwordStrength.ts b/modules/app/composables/passwordStrength.ts new file mode 100644 index 0000000..128f941 --- /dev/null +++ b/modules/app/composables/passwordStrength.ts @@ -0,0 +1,42 @@ +import { zxcvbn, zxcvbnOptions, type ZxcvbnResult } from '@zxcvbn-ts/core' +import * as zxcvbnCommonPackage from '@zxcvbn-ts/language-common' +import * as zxcvbnEnPackage from '@zxcvbn-ts/language-fr' + +export const usePasswordStrength = (password: Ref) => { + + // 0 # too guessable: risky password. (guesses < 10 ^ 3) + // 1 # very guessable: protection from throttled online attacks. (guesses < 10 ^ 6) + // 2 # somewhat guessable: protection from unthrottled online attacks. (guesses < 10 ^ 8) + // 3 # safely unguessable: moderate protection from offline slow - hash scenario. (guesses < 10 ^ 10) + // 4 # very unguessable: strong protection from offline slow - hash scenario. (guesses >= 10 ^ 10) + + const strength = ref>({ + score: 0, + }) + + const options = { + translations: zxcvbnEnPackage.translations, + graphs: zxcvbnCommonPackage.adjacencyGraphs, + dictionary: { + ...zxcvbnCommonPackage.dictionary, + ...zxcvbnEnPackage.dictionary, + }, + } + + zxcvbnOptions.setOptions(options) + + watchDebounced(password, (newPassword) => { + if (!newPassword) { + strength.value = { + score: 0, + } + return + } + + strength.value = zxcvbn(newPassword.trim()) + }, { immediate: true, debounce: 500 }) + + return { + strength, + } +} \ No newline at end of file diff --git a/modules/app/layouts/default.vue b/modules/app/layouts/default.vue index 9995ce6..c7f8af1 100644 --- a/modules/app/layouts/default.vue +++ b/modules/app/layouts/default.vue @@ -1,30 +1,13 @@