create-nuxt-base 0.3.17 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.github/workflows/publish.yml +4 -2
  2. package/.oxfmtrc.jsonc +7 -0
  3. package/CHANGELOG.md +20 -8
  4. package/nuxt-base-template/.dockerignore +44 -0
  5. package/nuxt-base-template/.nuxtrc +1 -0
  6. package/nuxt-base-template/.oxfmtrc.jsonc +8 -0
  7. package/nuxt-base-template/Dockerfile.dev +23 -0
  8. package/nuxt-base-template/app/components/Modal/ModalBackupCodes.vue +117 -0
  9. package/nuxt-base-template/app/components/Upload/TusFileUpload.vue +302 -0
  10. package/nuxt-base-template/app/composables/use-better-auth.ts +25 -0
  11. package/nuxt-base-template/app/composables/use-file.ts +39 -4
  12. package/nuxt-base-template/app/composables/use-share.ts +1 -1
  13. package/nuxt-base-template/app/composables/use-tus-upload.ts +278 -0
  14. package/nuxt-base-template/app/interfaces/upload.interface.ts +58 -0
  15. package/nuxt-base-template/app/interfaces/user.interface.ts +12 -0
  16. package/nuxt-base-template/app/lib/auth-client.ts +135 -0
  17. package/nuxt-base-template/app/middleware/admin.global.ts +23 -0
  18. package/nuxt-base-template/app/middleware/auth.global.ts +18 -0
  19. package/nuxt-base-template/app/middleware/guest.global.ts +18 -0
  20. package/nuxt-base-template/app/pages/app/settings/security.vue +409 -0
  21. package/nuxt-base-template/app/pages/auth/2fa.vue +120 -0
  22. package/nuxt-base-template/app/pages/auth/forgot-password.vue +72 -21
  23. package/nuxt-base-template/app/pages/auth/login.vue +75 -11
  24. package/nuxt-base-template/app/pages/auth/register.vue +184 -0
  25. package/nuxt-base-template/app/pages/auth/reset-password.vue +153 -0
  26. package/nuxt-base-template/app/utils/crypto.ts +13 -0
  27. package/nuxt-base-template/docker-entrypoint.sh +21 -0
  28. package/nuxt-base-template/nuxt.config.ts +4 -1
  29. package/nuxt-base-template/oxlint.json +14 -0
  30. package/nuxt-base-template/package-lock.json +11582 -10675
  31. package/nuxt-base-template/package.json +35 -32
  32. package/nuxt-base-template/tests/iam.spec.ts +247 -0
  33. package/package.json +14 -11
  34. package/.eslintignore +0 -14
  35. package/.eslintrc +0 -3
  36. package/.prettierignore +0 -5
  37. package/.prettierrc +0 -6
  38. package/nuxt-base-template/CLAUDE.md +0 -361
  39. package/nuxt-base-template/app/pages/auth/reset-password/[token].vue +0 -110
  40. package/nuxt-base-template/app/public/favicon.ico +0 -0
  41. package/nuxt-base-template/eslint.config.mjs +0 -4
@@ -7,6 +7,13 @@ import type { InferOutput } from 'valibot';
7
7
 
8
8
  import * as v from 'valibot';
9
9
 
10
+ import { authClient } from '~/lib/auth-client';
11
+
12
+ // ============================================================================
13
+ // Composables
14
+ // ============================================================================
15
+ const toast = useToast();
16
+
10
17
  // ============================================================================
11
18
  // Page Meta
12
19
  // ============================================================================
@@ -17,35 +24,79 @@ definePageMeta({
17
24
  // ============================================================================
18
25
  // Variables
19
26
  // ============================================================================
27
+ const loading = ref<boolean>(false);
28
+ const passkeyLoading = ref<boolean>(false);
29
+
20
30
  const fields: AuthFormField[] = [
21
31
  {
22
- label: 'Email',
32
+ label: 'E-Mail',
23
33
  name: 'email',
24
- placeholder: 'Enter your email',
34
+ placeholder: 'E-Mail eingeben',
25
35
  required: true,
26
36
  type: 'email',
27
37
  },
28
38
  {
29
- label: 'Password',
39
+ label: 'Passwort',
30
40
  name: 'password',
31
- placeholder: 'Enter your password',
41
+ placeholder: 'Passwort eingeben',
32
42
  required: true,
33
43
  type: 'password',
34
44
  },
35
45
  ];
36
46
 
37
47
  const schema = v.object({
38
- email: v.pipe(v.string('Email is required'), v.email('Has to be a valid email address')),
39
- password: v.pipe(v.string('Password is required'), v.minLength(5, 'Must be at least 5 characters')),
48
+ email: v.pipe(v.string('E-Mail ist erforderlich'), v.email('Bitte eine gültige E-Mail eingeben')),
49
+ password: v.pipe(v.string('Passwort ist erforderlich'), v.minLength(5, 'Mindestens 5 Zeichen erforderlich')),
40
50
  });
41
51
 
42
52
  type Schema = InferOutput<typeof schema>;
43
53
 
54
+ async function onPasskeyLogin(): Promise<void> {
55
+ passkeyLoading.value = true;
56
+
57
+ try {
58
+ const { error } = await authClient.signIn.passkey();
59
+
60
+ if (error) {
61
+ toast.add({
62
+ color: 'error',
63
+ description: error.message || 'Passkey-Anmeldung fehlgeschlagen',
64
+ title: 'Fehler',
65
+ });
66
+ return;
67
+ }
68
+
69
+ await navigateTo('/app');
70
+ } finally {
71
+ passkeyLoading.value = false;
72
+ }
73
+ }
74
+
44
75
  // ============================================================================
45
76
  // Functions
46
77
  // ============================================================================
47
78
  async function onSubmit(payload: FormSubmitEvent<Schema>): Promise<void> {
48
- console.debug('Login request for:', payload.data.email);
79
+ loading.value = true;
80
+
81
+ try {
82
+ const { error } = await authClient.signIn.email({
83
+ email: payload.data.email,
84
+ password: payload.data.password,
85
+ });
86
+
87
+ if (error) {
88
+ toast.add({
89
+ color: 'error',
90
+ description: error.message || 'Anmeldung fehlgeschlagen',
91
+ title: 'Fehler',
92
+ });
93
+ return;
94
+ }
95
+
96
+ await navigateTo('/app');
97
+ } finally {
98
+ loading.value = false;
99
+ }
49
100
  }
50
101
  </script>
51
102
 
@@ -53,18 +104,31 @@ async function onSubmit(payload: FormSubmitEvent<Schema>): Promise<void> {
53
104
  <UPageCard class="w-md" variant="naked">
54
105
  <UAuthForm
55
106
  :schema="schema"
56
- title="Login"
107
+ title="Anmelden"
57
108
  icon="i-lucide-user"
58
109
  :fields="fields"
59
- loadingAuto
110
+ :loading="loading"
60
111
  :submit="{
61
- label: 'Log In',
112
+ label: 'Anmelden',
62
113
  block: true,
63
114
  }"
64
115
  @submit="onSubmit"
65
116
  >
66
117
  <template #password-hint>
67
- <ULink to="/auth/forgot-password" class="text-primary font-medium" tabindex="-1">Forgot your password? </ULink>
118
+ <ULink to="/auth/forgot-password" class="text-primary font-medium" tabindex="-1">Passwort vergessen?</ULink>
119
+ </template>
120
+
121
+ <template #footer>
122
+ <div class="flex flex-col gap-4">
123
+ <USeparator label="oder" />
124
+
125
+ <UButton block color="neutral" variant="outline" icon="i-lucide-key" :loading="passkeyLoading" @click="onPasskeyLogin"> Mit Passkey anmelden </UButton>
126
+
127
+ <p class="text-center text-sm text-muted">
128
+ Noch kein Konto?
129
+ <ULink to="/auth/register" class="text-primary font-medium">Registrieren</ULink>
130
+ </p>
131
+ </div>
68
132
  </template>
69
133
  </UAuthForm>
70
134
  </UPageCard>
@@ -0,0 +1,184 @@
1
+ <script setup lang="ts">
2
+ // ============================================================================
3
+ // Imports
4
+ // ============================================================================
5
+ import type { AuthFormField, FormSubmitEvent } from '@nuxt/ui';
6
+ import type { InferOutput } from 'valibot';
7
+
8
+ import * as v from 'valibot';
9
+
10
+ import { authClient } from '~/lib/auth-client';
11
+
12
+ // ============================================================================
13
+ // Composables
14
+ // ============================================================================
15
+ const toast = useToast();
16
+
17
+ // ============================================================================
18
+ // Page Meta
19
+ // ============================================================================
20
+ definePageMeta({
21
+ layout: 'slim',
22
+ });
23
+
24
+ // ============================================================================
25
+ // Variables
26
+ // ============================================================================
27
+ const loading = ref<boolean>(false);
28
+ const showPasskeyPrompt = ref<boolean>(false);
29
+ const passkeyLoading = ref<boolean>(false);
30
+
31
+ const fields: AuthFormField[] = [
32
+ {
33
+ label: 'Name',
34
+ name: 'name',
35
+ placeholder: 'Name eingeben',
36
+ required: true,
37
+ type: 'text',
38
+ },
39
+ {
40
+ label: 'E-Mail',
41
+ name: 'email',
42
+ placeholder: 'E-Mail eingeben',
43
+ required: true,
44
+ type: 'email',
45
+ },
46
+ {
47
+ label: 'Passwort',
48
+ name: 'password',
49
+ placeholder: 'Passwort eingeben',
50
+ required: true,
51
+ type: 'password',
52
+ },
53
+ {
54
+ label: 'Passwort bestätigen',
55
+ name: 'confirmPassword',
56
+ placeholder: 'Passwort wiederholen',
57
+ required: true,
58
+ type: 'password',
59
+ },
60
+ ];
61
+
62
+ const schema = v.pipe(
63
+ v.object({
64
+ confirmPassword: v.pipe(v.string('Passwortbestätigung ist erforderlich'), v.minLength(8, 'Mindestens 8 Zeichen erforderlich')),
65
+ email: v.pipe(v.string('E-Mail ist erforderlich'), v.email('Bitte eine gültige E-Mail eingeben')),
66
+ name: v.pipe(v.string('Name ist erforderlich'), v.minLength(2, 'Mindestens 2 Zeichen erforderlich')),
67
+ password: v.pipe(v.string('Passwort ist erforderlich'), v.minLength(8, 'Mindestens 8 Zeichen erforderlich')),
68
+ }),
69
+ v.forward(
70
+ v.partialCheck([['password'], ['confirmPassword']], (input) => input.password === input.confirmPassword, 'Passwörter stimmen nicht überein'),
71
+ ['confirmPassword'],
72
+ ),
73
+ );
74
+
75
+ type Schema = InferOutput<typeof schema>;
76
+
77
+ async function addPasskey(): Promise<void> {
78
+ passkeyLoading.value = true;
79
+
80
+ try {
81
+ const { error } = await authClient.passkey.addPasskey({
82
+ name: 'Mein Gerät',
83
+ });
84
+
85
+ if (error) {
86
+ toast.add({
87
+ color: 'error',
88
+ description: error.message || 'Passkey konnte nicht hinzugefügt werden',
89
+ title: 'Fehler',
90
+ });
91
+ return;
92
+ }
93
+
94
+ toast.add({
95
+ color: 'success',
96
+ description: 'Passkey wurde erfolgreich hinzugefügt',
97
+ title: 'Erfolg',
98
+ });
99
+
100
+ await navigateTo('/app');
101
+ } finally {
102
+ passkeyLoading.value = false;
103
+ }
104
+ }
105
+
106
+ // ============================================================================
107
+ // Functions
108
+ // ============================================================================
109
+ async function onSubmit(payload: FormSubmitEvent<Schema>): Promise<void> {
110
+ loading.value = true;
111
+
112
+ try {
113
+ const { error } = await authClient.signUp.email({
114
+ email: payload.data.email,
115
+ name: payload.data.name,
116
+ password: payload.data.password,
117
+ });
118
+
119
+ if (error) {
120
+ toast.add({
121
+ color: 'error',
122
+ description: error.message || 'Registrierung fehlgeschlagen',
123
+ title: 'Fehler',
124
+ });
125
+ return;
126
+ }
127
+
128
+ toast.add({
129
+ color: 'success',
130
+ description: 'Dein Konto wurde erfolgreich erstellt',
131
+ title: 'Willkommen!',
132
+ });
133
+
134
+ showPasskeyPrompt.value = true;
135
+ } finally {
136
+ loading.value = false;
137
+ }
138
+ }
139
+
140
+ async function skipPasskey(): Promise<void> {
141
+ await navigateTo('/app');
142
+ }
143
+ </script>
144
+
145
+ <template>
146
+ <UPageCard class="w-md" variant="naked">
147
+ <template v-if="!showPasskeyPrompt">
148
+ <UAuthForm
149
+ :schema="schema"
150
+ title="Registrieren"
151
+ icon="i-lucide-user-plus"
152
+ :fields="fields"
153
+ :loading="loading"
154
+ :submit="{
155
+ label: 'Konto erstellen',
156
+ block: true,
157
+ }"
158
+ @submit="onSubmit"
159
+ >
160
+ <template #footer>
161
+ <p class="text-center text-sm text-muted">
162
+ Bereits ein Konto?
163
+ <ULink to="/auth/login" class="text-primary font-medium">Anmelden</ULink>
164
+ </p>
165
+ </template>
166
+ </UAuthForm>
167
+ </template>
168
+
169
+ <template v-else>
170
+ <div class="flex flex-col items-center gap-6">
171
+ <UIcon name="i-lucide-key" class="size-16 text-primary" />
172
+ <div class="text-center">
173
+ <h2 class="text-xl font-semibold">Passkey hinzufügen?</h2>
174
+ <p class="mt-2 text-sm text-muted">Mit einem Passkey kannst du dich schnell und sicher ohne Passwort anmelden.</p>
175
+ </div>
176
+
177
+ <div class="flex w-full flex-col gap-3">
178
+ <UButton block :loading="passkeyLoading" @click="addPasskey"> Passkey hinzufügen </UButton>
179
+ <UButton block variant="outline" color="neutral" @click="skipPasskey"> Später einrichten </UButton>
180
+ </div>
181
+ </div>
182
+ </template>
183
+ </UPageCard>
184
+ </template>
@@ -0,0 +1,153 @@
1
+ <script setup lang="ts">
2
+ // ============================================================================
3
+ // Imports
4
+ // ============================================================================
5
+ import type { AuthFormField, FormSubmitEvent } from '@nuxt/ui';
6
+ import type { InferOutput } from 'valibot';
7
+
8
+ import * as v from 'valibot';
9
+
10
+ import { authClient } from '~/lib/auth-client';
11
+
12
+ // ============================================================================
13
+ // Composables
14
+ // ============================================================================
15
+ const route = useRoute();
16
+ const toast = useToast();
17
+
18
+ // ============================================================================
19
+ // Page Meta
20
+ // ============================================================================
21
+ definePageMeta({
22
+ layout: 'slim',
23
+ });
24
+
25
+ // ============================================================================
26
+ // Variables
27
+ // ============================================================================
28
+ const token = computed<string>(() => {
29
+ const queryToken = route.query.token;
30
+ return typeof queryToken === 'string' ? queryToken : '';
31
+ });
32
+
33
+ const isTokenValid = computed<boolean>(() => token.value.length > 0);
34
+ const loading = ref<boolean>(false);
35
+ const resetSuccess = ref<boolean>(false);
36
+
37
+ const fields: AuthFormField[] = [
38
+ {
39
+ label: 'Neues Passwort',
40
+ name: 'password',
41
+ placeholder: 'Neues Passwort eingeben',
42
+ required: true,
43
+ type: 'password',
44
+ },
45
+ {
46
+ label: 'Passwort bestätigen',
47
+ name: 'confirmPassword',
48
+ placeholder: 'Passwort wiederholen',
49
+ required: true,
50
+ type: 'password',
51
+ },
52
+ ];
53
+
54
+ const schema = v.pipe(
55
+ v.object({
56
+ confirmPassword: v.pipe(v.string('Passwortbestätigung ist erforderlich'), v.minLength(8, 'Mindestens 8 Zeichen erforderlich')),
57
+ password: v.pipe(v.string('Passwort ist erforderlich'), v.minLength(8, 'Mindestens 8 Zeichen erforderlich')),
58
+ }),
59
+ v.forward(
60
+ v.partialCheck([['password'], ['confirmPassword']], (input) => input.password === input.confirmPassword, 'Passwörter stimmen nicht überein'),
61
+ ['confirmPassword'],
62
+ ),
63
+ );
64
+
65
+ type Schema = InferOutput<typeof schema>;
66
+
67
+ // ============================================================================
68
+ // Lifecycle Hooks
69
+ // ============================================================================
70
+ onMounted(() => {
71
+ if (!isTokenValid.value) {
72
+ toast.add({
73
+ color: 'error',
74
+ description: 'Der Link zum Zurücksetzen des Passworts ist ungültig oder fehlt.',
75
+ title: 'Ungültiger Link',
76
+ });
77
+ }
78
+ });
79
+
80
+ // ============================================================================
81
+ // Functions
82
+ // ============================================================================
83
+ async function onSubmit(payload: FormSubmitEvent<Schema>): Promise<void> {
84
+ loading.value = true;
85
+
86
+ try {
87
+ const { error } = await authClient.resetPassword({
88
+ newPassword: payload.data.password,
89
+ token: token.value,
90
+ });
91
+
92
+ if (error) {
93
+ toast.add({
94
+ color: 'error',
95
+ description: error.message || 'Passwort konnte nicht zurückgesetzt werden',
96
+ title: 'Fehler',
97
+ });
98
+ return;
99
+ }
100
+
101
+ resetSuccess.value = true;
102
+ } finally {
103
+ loading.value = false;
104
+ }
105
+ }
106
+ </script>
107
+
108
+ <template>
109
+ <UPageCard class="w-md" variant="naked">
110
+ <template v-if="resetSuccess">
111
+ <div class="flex flex-col items-center gap-6">
112
+ <UIcon name="i-lucide-check-circle" class="size-16 text-success" />
113
+ <div class="text-center">
114
+ <h2 class="text-xl font-semibold">Passwort zurückgesetzt</h2>
115
+ <p class="mt-2 text-sm text-muted">Dein Passwort wurde erfolgreich geändert. Du kannst dich jetzt mit deinem neuen Passwort anmelden.</p>
116
+ </div>
117
+
118
+ <UButton to="/auth/login" block> Zur Anmeldung </UButton>
119
+ </div>
120
+ </template>
121
+
122
+ <template v-else>
123
+ <UAlert
124
+ v-if="!isTokenValid"
125
+ color="error"
126
+ description="Der Link zum Zurücksetzen des Passworts ist ungültig oder fehlt. Bitte fordere einen neuen Link an."
127
+ icon="i-lucide-alert-triangle"
128
+ title="Ungültiger Link"
129
+ class="mb-4"
130
+ />
131
+
132
+ <UAuthForm
133
+ :schema="schema"
134
+ title="Neues Passwort"
135
+ icon="i-lucide-shield-check"
136
+ :fields="fields"
137
+ :loading="loading"
138
+ :submit="{
139
+ label: 'Passwort speichern',
140
+ block: true,
141
+ disabled: !isTokenValid,
142
+ }"
143
+ @submit="onSubmit"
144
+ >
145
+ <template #footer>
146
+ <p class="text-center text-sm text-muted">
147
+ <ULink to="/auth/forgot-password" class="text-primary font-medium"> Neuen Link anfordern </ULink>
148
+ </p>
149
+ </template>
150
+ </UAuthForm>
151
+ </template>
152
+ </UPageCard>
153
+ </template>
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Hashes a string using SHA256
3
+ * Uses the Web Crypto API which is available in all modern browsers
4
+ *
5
+ * @param message - The string to hash
6
+ * @returns The SHA256 hash as a lowercase hex string (64 characters)
7
+ */
8
+ export async function sha256(message: string): Promise<string> {
9
+ const msgBuffer = new TextEncoder().encode(message);
10
+ const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
11
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
12
+ return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
13
+ }
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ # Check if node_modules exists and if package.json has changed
5
+ PACKAGE_HASH_FILE="/app/.package-hash"
6
+ CURRENT_HASH=$(md5sum /app/package.json /app/package-lock.json 2>/dev/null | md5sum | cut -d' ' -f1)
7
+
8
+ if [ ! -d "/app/node_modules" ] || [ ! -f "$PACKAGE_HASH_FILE" ] || [ "$(cat $PACKAGE_HASH_FILE 2>/dev/null)" != "$CURRENT_HASH" ]; then
9
+ echo "Installing dependencies..."
10
+ npm ci
11
+ echo "$CURRENT_HASH" > "$PACKAGE_HASH_FILE"
12
+ echo "Dependencies installed successfully."
13
+ else
14
+ echo "Dependencies are up to date."
15
+ fi
16
+
17
+ # Prepare Nuxt (generate types, etc.)
18
+ echo "Preparing Nuxt..."
19
+ npx nuxt prepare
20
+
21
+ exec "$@"
@@ -110,8 +110,11 @@ export default defineNuxtConfig({
110
110
  // Runtime Configuration (Environment Variables)
111
111
  // ============================================================================
112
112
  runtimeConfig: {
113
+ // Server-only (for SSR requests)
114
+ apiUrl: process.env.API_URL || 'http://localhost:3000',
113
115
  public: {
114
- apiUrl: process.env.API_URL || 'http://localhost:3000',
116
+ // Client-side (browser requests)
117
+ apiUrl: process.env.API_URL_BROWSER || process.env.API_URL || 'http://localhost:3000',
115
118
  host: process.env.API_URL,
116
119
  webPushKey: process.env.WEB_PUSH_KEY,
117
120
  },
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": ["typescript", "vue", "unicorn", "import"],
4
+ "env": {
5
+ "browser": true,
6
+ "node": true
7
+ },
8
+ "rules": {
9
+ "eqeqeq": "warn",
10
+ "no-console": "warn",
11
+ "no-unused-vars": "warn",
12
+ "@typescript-eslint/no-explicit-any": "warn"
13
+ }
14
+ }