@lenne.tech/nuxt-extensions 1.2.8 → 1.2.11

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.
package/dist/module.d.mts CHANGED
@@ -2,7 +2,7 @@ import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { LtExtensionsModuleOptions } from '../dist/runtime/types/index.js';
3
3
  export { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn } from '../dist/runtime/types/auth.js';
4
4
  export { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn } from '../dist/runtime/types/upload.js';
5
- export { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtTusModuleOptions } from '../dist/runtime/types/module.js';
5
+ export { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions } from '../dist/runtime/types/module.js';
6
6
  export { LtErrorTranslationResponse, LtParsedError, UseLtErrorTranslationReturn } from '../dist/runtime/types/error.js';
7
7
 
8
8
  declare const name = "@lenne.tech/nuxt-extensions";
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addImports, addComponent, addPlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addImports, addComponent, addPlugin, addRouteMiddleware } from '@nuxt/kit';
2
2
 
3
3
  const name = "@lenne.tech/nuxt-extensions";
4
4
  const version = "1.0.0";
@@ -16,6 +16,10 @@ const defaultOptions = {
16
16
  publicPaths: []
17
17
  },
18
18
  loginPath: "/auth/login",
19
+ systemSetup: {
20
+ enabled: false,
21
+ setupPath: "/auth/setup"
22
+ },
19
23
  twoFactorRedirectPath: "/auth/2fa"
20
24
  },
21
25
  errorTranslation: {
@@ -41,7 +45,11 @@ const module$1 = defineNuxtModule({
41
45
  async setup(options, nuxt) {
42
46
  const { resolve } = createResolver(import.meta.url);
43
47
  const resolvedOptions = {
44
- auth: { ...defaultOptions.auth, ...options.auth },
48
+ auth: {
49
+ ...defaultOptions.auth,
50
+ ...options.auth,
51
+ systemSetup: { ...defaultOptions.auth.systemSetup, ...options.auth?.systemSetup }
52
+ },
45
53
  errorTranslation: { ...defaultOptions.errorTranslation, ...options.errorTranslation },
46
54
  i18n: { ...defaultOptions.i18n, ...options.i18n },
47
55
  tus: { ...defaultOptions.tus, ...options.tus }
@@ -59,6 +67,10 @@ const module$1 = defineNuxtModule({
59
67
  publicPaths: resolvedOptions.auth?.interceptor?.publicPaths || []
60
68
  },
61
69
  loginPath: resolvedOptions.auth?.loginPath || "/auth/login",
70
+ systemSetup: {
71
+ enabled: resolvedOptions.auth?.systemSetup?.enabled ?? false,
72
+ setupPath: resolvedOptions.auth?.systemSetup?.setupPath || "/auth/setup"
73
+ },
62
74
  twoFactorRedirectPath: resolvedOptions.auth?.twoFactorRedirectPath || "/auth/2fa"
63
75
  },
64
76
  errorTranslation: {
@@ -82,6 +94,7 @@ const module$1 = defineNuxtModule({
82
94
  { name: "useLtFile", from: resolve("./runtime/composables/use-lt-file") },
83
95
  { name: "useLtTusUpload", from: resolve("./runtime/composables/use-lt-tus-upload") },
84
96
  { name: "useLtShare", from: resolve("./runtime/composables/use-lt-share") },
97
+ { name: "useSystemSetup", from: resolve("./runtime/composables/auth/use-system-setup") },
85
98
  // Utils
86
99
  { name: "ltSha256", from: resolve("./runtime/utils/crypto") },
87
100
  { name: "ltArrayBufferToBase64Url", from: resolve("./runtime/utils/crypto") },
@@ -119,6 +132,13 @@ const module$1 = defineNuxtModule({
119
132
  if (resolvedOptions.auth?.enabled && resolvedOptions.auth?.interceptor?.enabled) {
120
133
  addPlugin(resolve("./runtime/plugins/auth-interceptor.client"));
121
134
  }
135
+ if (resolvedOptions.auth?.systemSetup?.enabled) {
136
+ addRouteMiddleware({
137
+ name: "lt-system-setup",
138
+ path: resolve("./runtime/middleware/setup"),
139
+ global: true
140
+ });
141
+ }
122
142
  if (resolvedOptions.errorTranslation?.enabled) {
123
143
  addPlugin(resolve("./runtime/plugins/error-translation.client"));
124
144
  }
@@ -25,10 +25,10 @@ declare var __VLS_7: {};
25
25
  type __VLS_Slots = {} & {
26
26
  default?: (props: typeof __VLS_7) => any;
27
27
  };
28
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
28
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
29
  leaveDuration: `${number}` | number;
30
30
  startDuration: `${number}` | number;
31
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
32
32
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
33
33
  declare const _default: typeof __VLS_export;
34
34
  export default _default;
@@ -25,10 +25,10 @@ declare var __VLS_7: {};
25
25
  type __VLS_Slots = {} & {
26
26
  default?: (props: typeof __VLS_7) => any;
27
27
  };
28
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
28
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
29
  leaveDuration: `${number}` | number;
30
30
  startDuration: `${number}` | number;
31
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
31
+ }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
32
32
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
33
33
  declare const _default: typeof __VLS_export;
34
34
  export default _default;
@@ -28,10 +28,10 @@ declare var __VLS_7: {};
28
28
  type __VLS_Slots = {} & {
29
29
  default?: (props: typeof __VLS_7) => any;
30
30
  };
31
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
31
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
32
32
  leaveDuration: `${number}` | number;
33
33
  startDuration: `${number}` | number;
34
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
35
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
36
36
  declare const _default: typeof __VLS_export;
37
37
  export default _default;
@@ -28,10 +28,10 @@ declare var __VLS_7: {};
28
28
  type __VLS_Slots = {} & {
29
29
  default?: (props: typeof __VLS_7) => any;
30
30
  };
31
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
31
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
32
32
  leaveDuration: `${number}` | number;
33
33
  startDuration: `${number}` | number;
34
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ }, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, false, {}, any>;
35
35
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
36
36
  declare const _default: typeof __VLS_export;
37
37
  export default _default;
@@ -2,7 +2,7 @@ declare var __VLS_7: {};
2
2
  type __VLS_Slots = {} & {
3
3
  default?: (props: typeof __VLS_7) => any;
4
4
  };
5
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  export default _default;
@@ -2,7 +2,7 @@ declare var __VLS_7: {};
2
2
  type __VLS_Slots = {} & {
3
3
  default?: (props: typeof __VLS_7) => any;
4
4
  };
5
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  export default _default;
@@ -2,7 +2,7 @@ declare var __VLS_7: {};
2
2
  type __VLS_Slots = {} & {
3
3
  default?: (props: typeof __VLS_7) => any;
4
4
  };
5
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  export default _default;
@@ -2,7 +2,7 @@ declare var __VLS_7: {};
2
2
  type __VLS_Slots = {} & {
3
3
  default?: (props: typeof __VLS_7) => any;
4
4
  };
5
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  export default _default;
@@ -2,7 +2,7 @@ declare var __VLS_7: {};
2
2
  type __VLS_Slots = {} & {
3
3
  default?: (props: typeof __VLS_7) => any;
4
4
  };
5
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  export default _default;
@@ -2,7 +2,7 @@ declare var __VLS_7: {};
2
2
  type __VLS_Slots = {} & {
3
3
  default?: (props: typeof __VLS_7) => any;
4
4
  };
5
- declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
5
+ declare const __VLS_base: import("@vue/runtime-core").DefineComponent<{}, {}, {}, {}, {}, import("@vue/runtime-core").ComponentOptionsMixin, import("@vue/runtime-core").ComponentOptionsMixin, {}, string, import("@vue/runtime-core").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("@vue/runtime-core").ComponentProvideOptions, true, {}, any>;
6
6
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
7
  declare const _default: typeof __VLS_export;
8
8
  export default _default;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * System Setup Composable
3
+ *
4
+ * Checks whether the system needs initial setup (first admin user creation)
5
+ * and provides a method to perform that setup.
6
+ *
7
+ * Uses useState for SSR-compatible state management.
8
+ */
9
+ import type { ComputedRef } from "vue";
10
+ export interface UseSystemSetupReturn {
11
+ /** Whether the system needs initial setup (null = not checked yet) */
12
+ needsSetup: ComputedRef<boolean | null>;
13
+ /** Check setup status from the backend */
14
+ checkSetupStatus: () => Promise<boolean>;
15
+ /** Initialize the system with the first admin user */
16
+ initSetup: (params: {
17
+ email: string;
18
+ password: string;
19
+ name: string;
20
+ }) => Promise<void>;
21
+ }
22
+ /**
23
+ * Composable for system setup flow (first admin user creation)
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const { needsSetup, checkSetupStatus, initSetup } = useSystemSetup();
28
+ *
29
+ * await checkSetupStatus();
30
+ * if (needsSetup.value) {
31
+ * await initSetup({ email: 'admin@example.com', password: 'secret', name: 'Admin' });
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function useSystemSetup(): UseSystemSetupReturn;
@@ -0,0 +1,43 @@
1
+ import { computed, useRuntimeConfig, useState } from "#imports";
2
+ import { getLtApiBase } from "../../lib/auth-state.js";
3
+ import { ltSha256 } from "../../utils/crypto.js";
4
+ export function useSystemSetup() {
5
+ const runtimeConfig = useRuntimeConfig();
6
+ const needsSetupState = useState("lt-needs-setup", () => null);
7
+ const needsSetup = computed(() => needsSetupState.value);
8
+ async function checkSetupStatus() {
9
+ try {
10
+ let url;
11
+ if (import.meta.server) {
12
+ const apiUrl = runtimeConfig.apiUrl || "http://localhost:3000";
13
+ url = `${apiUrl}/api/system-setup/status`;
14
+ } else {
15
+ url = "/api/system-setup/status";
16
+ }
17
+ const data = await $fetch(url);
18
+ needsSetupState.value = data.needsSetup;
19
+ return data.needsSetup;
20
+ } catch {
21
+ needsSetupState.value = false;
22
+ return false;
23
+ }
24
+ }
25
+ async function initSetup(params) {
26
+ const apiBase = getLtApiBase();
27
+ const hashedPassword = await ltSha256(params.password);
28
+ await $fetch(`${apiBase}/system-setup/init`, {
29
+ method: "POST",
30
+ body: {
31
+ email: params.email,
32
+ password: hashedPassword,
33
+ name: params.name
34
+ }
35
+ });
36
+ needsSetupState.value = false;
37
+ }
38
+ return {
39
+ needsSetup,
40
+ checkSetupStatus,
41
+ initSetup
42
+ };
43
+ }
@@ -1,4 +1,5 @@
1
1
  export { useLtAuth } from "./auth/use-lt-auth.js";
2
+ export { useSystemSetup } from "./auth/use-system-setup.js";
2
3
  export { useLtAuthClient, ltAuthClient } from "./use-lt-auth-client.js";
3
4
  export { useLtTusUpload } from "./use-lt-tus-upload.js";
4
5
  export { useLtFile } from "./use-lt-file.js";
@@ -1,4 +1,5 @@
1
1
  export { useLtAuth } from "./auth/use-lt-auth.js";
2
+ export { useSystemSetup } from "./auth/use-system-setup.js";
2
3
  export { useLtAuthClient, ltAuthClient } from "./use-lt-auth-client.js";
3
4
  export { useLtTusUpload } from "./use-lt-tus-upload.js";
4
5
  export { useLtFile } from "./use-lt-file.js";
@@ -101,7 +101,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
101
101
  } | null;
102
102
  readonly isPending: boolean;
103
103
  readonly isRefetching: boolean;
104
- readonly error: import("@better-fetch/fetch").BetterFetchError | null;
104
+ readonly error: import("better-auth/client").BetterFetchError | null;
105
105
  readonly refetch: (queryParams?: {
106
106
  query?: import("better-auth").SessionQueryParams;
107
107
  } | undefined) => Promise<void>;
@@ -129,7 +129,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
129
129
  } | null;
130
130
  readonly isPending: boolean;
131
131
  readonly isRefetching: boolean;
132
- readonly error: import("@better-fetch/fetch").BetterFetchError | null;
132
+ readonly error: import("better-auth/client").BetterFetchError | null;
133
133
  readonly refetch: (queryParams?: {
134
134
  query?: import("better-auth").SessionQueryParams;
135
135
  } | undefined) => Promise<void>;
@@ -209,21 +209,21 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
209
209
  };
210
210
  };
211
211
  };
212
- $fetch: import("@better-fetch/fetch").BetterFetch<{
213
- plugins: (import("@better-fetch/fetch").BetterFetchPlugin<Record<string, any>> | {
212
+ $fetch: import("better-auth/client").BetterFetch<{
213
+ plugins: (import("better-auth/client").BetterFetchPlugin<Record<string, any>> | {
214
214
  id: string;
215
215
  name: string;
216
216
  hooks: {
217
- onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): void;
217
+ onSuccess(context: import("better-auth/client").SuccessContext<any>): void;
218
218
  };
219
219
  } | {
220
220
  id: string;
221
221
  name: string;
222
222
  hooks: {
223
- onSuccess: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
224
- onError: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
225
- onRequest: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
226
- onResponse: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
223
+ onSuccess: ((context: import("better-auth/client").SuccessContext<any>) => Promise<void> | void) | undefined;
224
+ onError: ((context: import("better-auth/client").ErrorContext) => Promise<void> | void) | undefined;
225
+ onRequest: (<T extends Record<string, any>>(context: import("better-auth/client").RequestContext<T>) => Promise<import("better-auth/client").RequestContext | void> | import("better-auth/client").RequestContext | void) | undefined;
226
+ onResponse: ((context: import("better-auth/client").ResponseContext) => Promise<Response | void | import("better-auth/client").ResponseContext> | Response | import("better-auth/client").ResponseContext | void) | undefined;
227
227
  };
228
228
  })[];
229
229
  cache?: RequestCache | undefined;
@@ -243,12 +243,12 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
243
243
  referrer?: string | undefined;
244
244
  referrerPolicy?: ReferrerPolicy | undefined;
245
245
  signal?: (AbortSignal | null) | undefined;
246
- onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
246
+ onRetry?: ((response: import("better-auth/client").ResponseContext) => Promise<void> | void) | undefined;
247
247
  hookOptions?: {
248
248
  cloneResponse?: boolean;
249
249
  } | undefined;
250
250
  timeout?: number | undefined;
251
- customFetchImpl: import("@better-fetch/fetch").FetchEsque;
251
+ customFetchImpl: import("better-auth/client").FetchEsque;
252
252
  baseURL: string;
253
253
  throw?: boolean | undefined;
254
254
  auth?: ({
@@ -268,17 +268,17 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
268
268
  params?: any;
269
269
  duplex?: "full" | "half" | undefined;
270
270
  jsonParser: (text: string) => Promise<any> | any;
271
- retry?: import("@better-fetch/fetch").RetryOptions | undefined;
271
+ retry?: import("better-auth/client").RetryOptions | undefined;
272
272
  retryAttempt?: number | undefined;
273
- output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
274
- errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
273
+ output?: (import("better-auth/client").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
274
+ errorSchema?: import("better-auth/client").StandardSchemaV1 | undefined;
275
275
  disableValidation?: boolean | undefined;
276
276
  disableSignal?: boolean | undefined;
277
277
  }, unknown, unknown, {}>;
278
278
  $store: {
279
279
  notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
280
280
  listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
281
- atoms: Record<string, import("nanostores").WritableAtom<any>>;
281
+ atoms: Record<string, import("better-auth/client").WritableAtom<any>>;
282
282
  };
283
283
  /**
284
284
  * Change password for an authenticated user (both passwords are hashed)
@@ -429,7 +429,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
429
429
  additionalData?: Record<string, any> | undefined;
430
430
  } & {
431
431
  fetchOptions?: FetchOptions | undefined;
432
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<NonNullable<{
432
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<{
433
433
  redirect: boolean;
434
434
  url: string;
435
435
  } | {
@@ -453,7 +453,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
453
453
  signOut: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
454
454
  query?: Record<string, any> | undefined;
455
455
  fetchOptions?: FetchOptions | undefined;
456
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
456
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
457
457
  success: boolean;
458
458
  }, {
459
459
  code?: string | undefined;
@@ -534,7 +534,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
534
534
  callbackURL?: string | undefined;
535
535
  };
536
536
  fetchOptions?: FetchOptions | undefined;
537
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<NonNullable<void | {
537
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<NonNullable<void | {
538
538
  status: boolean;
539
539
  }>, {
540
540
  code?: string | undefined;
@@ -548,7 +548,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
548
548
  callbackURL?: string | undefined;
549
549
  } & {
550
550
  fetchOptions?: FetchOptions | undefined;
551
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
551
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
552
552
  status: boolean;
553
553
  }, {
554
554
  code?: string | undefined;
@@ -562,7 +562,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
562
562
  callbackURL?: string | undefined;
563
563
  } & {
564
564
  fetchOptions?: FetchOptions | undefined;
565
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
565
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
566
566
  status: boolean;
567
567
  }, {
568
568
  code?: string | undefined;
@@ -575,7 +575,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
575
575
  image?: (string | null) | undefined;
576
576
  name?: string | undefined;
577
577
  fetchOptions?: FetchOptions | undefined;
578
- } & Partial<{}>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
578
+ } & Partial<{}>> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
579
579
  status: boolean;
580
580
  }, {
581
581
  code?: string | undefined;
@@ -591,7 +591,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
591
591
  token?: string | undefined;
592
592
  } & {
593
593
  fetchOptions?: FetchOptions | undefined;
594
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
594
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
595
595
  success: boolean;
596
596
  message: string;
597
597
  }, {
@@ -607,7 +607,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
607
607
  callbackURL?: string | undefined;
608
608
  };
609
609
  fetchOptions?: FetchOptions | undefined;
610
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
610
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
611
611
  success: boolean;
612
612
  message: string;
613
613
  }, {
@@ -623,7 +623,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
623
623
  redirectTo?: string | undefined;
624
624
  } & {
625
625
  fetchOptions?: FetchOptions | undefined;
626
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
626
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
627
627
  status: boolean;
628
628
  message: string;
629
629
  }, {
@@ -633,7 +633,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
633
633
  listSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
634
634
  query?: Record<string, any> | undefined;
635
635
  fetchOptions?: FetchOptions | undefined;
636
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<import("better-auth").Prettify<{
636
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<import("better-auth").Prettify<{
637
637
  id: string;
638
638
  createdAt: Date;
639
639
  updatedAt: Date;
@@ -652,7 +652,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
652
652
  token: string;
653
653
  } & {
654
654
  fetchOptions?: FetchOptions | undefined;
655
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
655
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
656
656
  status: boolean;
657
657
  }, {
658
658
  code?: string | undefined;
@@ -661,7 +661,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
661
661
  revokeSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
662
662
  query?: Record<string, any> | undefined;
663
663
  fetchOptions?: FetchOptions | undefined;
664
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
664
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
665
665
  status: boolean;
666
666
  }, {
667
667
  code?: string | undefined;
@@ -670,7 +670,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
670
670
  revokeOtherSessions: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
671
671
  query?: Record<string, any> | undefined;
672
672
  fetchOptions?: FetchOptions | undefined;
673
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
673
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
674
674
  status: boolean;
675
675
  }, {
676
676
  code?: string | undefined;
@@ -708,7 +708,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
708
708
  additionalData?: Record<string, any> | undefined;
709
709
  } & {
710
710
  fetchOptions?: FetchOptions | undefined;
711
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
711
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
712
712
  url: string;
713
713
  redirect: boolean;
714
714
  }, {
@@ -718,7 +718,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
718
718
  listAccounts: <FetchOptions extends import("better-auth").ClientFetchOption<never, Partial<Record<string, any>> & Record<string, any>, Record<string, any> | undefined>>(data_0?: import("better-auth").Prettify<{
719
719
  query?: Record<string, any> | undefined;
720
720
  fetchOptions?: FetchOptions | undefined;
721
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
721
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
722
722
  scopes: string[];
723
723
  id: string;
724
724
  createdAt: Date;
@@ -738,7 +738,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
738
738
  accountId?: string | undefined;
739
739
  } & {
740
740
  fetchOptions?: FetchOptions | undefined;
741
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
741
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
742
742
  status: boolean;
743
743
  }, {
744
744
  code?: string | undefined;
@@ -754,7 +754,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
754
754
  userId?: string | undefined;
755
755
  } & {
756
756
  fetchOptions?: FetchOptions | undefined;
757
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
757
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
758
758
  accessToken: string | undefined;
759
759
  refreshToken: string | undefined;
760
760
  accessTokenExpiresAt: Date | undefined;
@@ -777,7 +777,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
777
777
  userId?: string | undefined;
778
778
  } & {
779
779
  fetchOptions?: FetchOptions | undefined;
780
- }>, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
780
+ }>, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
781
781
  accessToken: string;
782
782
  accessTokenExpiresAt: Date | undefined;
783
783
  scopes: string[];
@@ -793,7 +793,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
793
793
  accountId?: string | undefined;
794
794
  } | undefined;
795
795
  fetchOptions?: FetchOptions | undefined;
796
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
796
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
797
797
  user: import("better-auth").OAuth2UserInfo;
798
798
  data: Record<string, any>;
799
799
  }, {
@@ -809,7 +809,7 @@ export declare function createLtAuthClient(config?: LtAuthClientConfig): {
809
809
  disableRefresh?: unknown;
810
810
  } | undefined;
811
811
  fetchOptions?: FetchOptions | undefined;
812
- }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("@better-fetch/fetch").BetterFetchResponse<{
812
+ }> | undefined, data_1?: FetchOptions | undefined) => Promise<import("better-auth/client").BetterFetchResponse<{
813
813
  user: {
814
814
  id: string;
815
815
  createdAt: Date;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * System Setup Middleware
3
+ *
4
+ * Global middleware that redirects to the setup page when the system
5
+ * needs initial setup (no admin user exists yet).
6
+ *
7
+ * - needsSetup === null -> calls checkSetupStatus()
8
+ * - needsSetup === true AND route != setupPath -> redirect to setupPath
9
+ * - needsSetup === false AND route === setupPath -> redirect to loginPath
10
+ */
11
+ declare const _default: import("nuxt/app").RouteMiddleware;
12
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { defineNuxtRouteMiddleware, navigateTo, useRuntimeConfig } from "#imports";
2
+ import { useSystemSetup } from "../composables/auth/use-system-setup.js";
3
+ export default defineNuxtRouteMiddleware(async (to) => {
4
+ const runtimeConfig = useRuntimeConfig();
5
+ const authConfig = runtimeConfig.public?.ltExtensions?.auth;
6
+ const setupPath = authConfig?.systemSetup?.setupPath || "/auth/setup";
7
+ const loginPath = authConfig?.loginPath || "/auth/login";
8
+ const { needsSetup, checkSetupStatus } = useSystemSetup();
9
+ try {
10
+ if (needsSetup.value === null) {
11
+ await checkSetupStatus();
12
+ }
13
+ if (needsSetup.value === true && to.path !== setupPath) {
14
+ return navigateTo(setupPath);
15
+ }
16
+ if (needsSetup.value === false && to.path === setupPath) {
17
+ return navigateTo(loginPath);
18
+ }
19
+ } catch {
20
+ }
21
+ });
@@ -17,7 +17,8 @@ export default (nuxtApp) => {
17
17
  "/auth/register",
18
18
  "/auth/forgot-password",
19
19
  "/auth/reset-password",
20
- "/auth/2fa"
20
+ "/auth/2fa",
21
+ "/auth/setup"
21
22
  ];
22
23
  const publicAuthPaths = [.../* @__PURE__ */ new Set([...defaultPublicPaths, ...configuredPublicPaths])];
23
24
  function isPublicAuthRoute() {
@@ -1,4 +1,4 @@
1
1
  export type { LtAuthClientConfig, LtAuthMode, LtAuthResponse, LtAuthState, LtPasskeyAuthResult, LtPasskeyRegisterResult, LtUser, UseLtAuthReturn, } from "./auth.js";
2
2
  export type { LtFileInfo, LtUploadItem, LtUploadOptions, LtUploadProgress, LtUploadStatus, UseLtFileReturn, UseLtTusUploadReturn, } from "./upload.js";
3
- export type { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtTusModuleOptions, } from "./module.js";
3
+ export type { LtAuthModuleOptions, LtErrorTranslationModuleOptions, LtExtensionsModuleOptions, LtExtensionsPublicRuntimeConfig, LtI18nModuleOptions, LtSystemSetupModuleOptions, LtTusModuleOptions, } from "./module.js";
4
4
  export type { LtErrorTranslationResponse, LtParsedError, UseLtErrorTranslationReturn, } from "./error.js";
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Auth module configuration options
3
3
  */
4
+ export interface LtSystemSetupModuleOptions {
5
+ /** Enable system setup flow (default: false) */
6
+ enabled?: boolean;
7
+ /** Path to the setup page (default: '/auth/setup') */
8
+ setupPath?: string;
9
+ }
4
10
  export interface LtAuthModuleOptions {
5
11
  /** Auth API base path (default: '/iam' - must match nest-server betterAuth.basePath) */
6
12
  basePath?: string;
@@ -23,6 +29,8 @@ export interface LtAuthModuleOptions {
23
29
  };
24
30
  /** Login page path for redirects (default: '/auth/login') */
25
31
  loginPath?: string;
32
+ /** System setup configuration */
33
+ systemSetup?: LtSystemSetupModuleOptions;
26
34
  /** 2FA redirect path (default: '/auth/2fa') */
27
35
  twoFactorRedirectPath?: string;
28
36
  }
@@ -81,6 +89,10 @@ export interface LtExtensionsPublicRuntimeConfig {
81
89
  publicPaths: string[];
82
90
  };
83
91
  loginPath: string;
92
+ systemSetup: {
93
+ enabled: boolean;
94
+ setupPath: string;
95
+ };
84
96
  twoFactorRedirectPath: string;
85
97
  };
86
98
  errorTranslation: {
package/dist/types.d.mts CHANGED
@@ -8,7 +8,7 @@ export { type LtAuthClientConfig, type LtAuthMode, type LtAuthResponse, type LtA
8
8
 
9
9
  export { type LtFileInfo, type LtUploadItem, type LtUploadOptions, type LtUploadProgress, type LtUploadStatus, type UseLtFileReturn, type UseLtTusUploadReturn } from '../dist/runtime/types/upload.js'
10
10
 
11
- export { type LtAuthModuleOptions, type LtErrorTranslationModuleOptions, type LtExtensionsModuleOptions, type LtExtensionsPublicRuntimeConfig, type LtI18nModuleOptions, type LtTusModuleOptions } from '../dist/runtime/types/module.js'
11
+ export { type LtAuthModuleOptions, type LtErrorTranslationModuleOptions, type LtExtensionsModuleOptions, type LtExtensionsPublicRuntimeConfig, type LtI18nModuleOptions, type LtSystemSetupModuleOptions, type LtTusModuleOptions } from '../dist/runtime/types/module.js'
12
12
 
13
13
  export { type LtErrorTranslationResponse, type LtParsedError, type UseLtErrorTranslationReturn } from '../dist/runtime/types/error.js'
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/nuxt-extensions",
3
- "version": "1.2.8",
3
+ "version": "1.2.11",
4
4
  "description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "author": "lenne.Tech <info@lenne.tech> (https://lenne.tech)",
14
14
  "license": "MIT",
15
+ "packageManager": "pnpm@10.29.2",
15
16
  "type": "module",
16
17
  "exports": {
17
18
  ".": {
@@ -47,8 +48,13 @@
47
48
  "scripts": {
48
49
  "prepare": "git config core.hooksPath .githooks",
49
50
  "prepack": "nuxt-module-build build",
50
- "check": "npm run format && npm run lint:fix && npm run test:types && npm run test",
51
- "dev": "npm run dev:prepare && nuxt dev playground",
51
+ "c": "pnpm run check",
52
+ "check": "pnpm audit && pnpm run format:check && pnpm run lint && pnpm test:types && pnpm test && pnpm run build",
53
+ "check:fix": "pnpm install && pnpm audit --fix && pnpm run format && pnpm run lint:fix && pnpm test:types && pnpm test && pnpm run build",
54
+ "check:naf": "pnpm install && pnpm run format && pnpm run lint:fix && pnpm test:types && pnpm test && pnpm run build",
55
+ "cf": "pnpm run check:fix",
56
+ "cnaf": "pnpm run check:naf",
57
+ "dev": "pnpm dev:prepare && nuxt dev playground",
52
58
  "dev:build": "nuxt build playground",
53
59
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
54
60
  "build": "nuxt-module-build build",
@@ -60,7 +66,7 @@
60
66
  "test:watch": "vitest watch",
61
67
  "test:coverage": "vitest run --coverage",
62
68
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
63
- "release": "npm run format:check && npm run lint && npm run test:types && npm run test && npm run prepack"
69
+ "release": "pnpm format:check && pnpm lint && pnpm test:types && pnpm test && pnpm prepack"
64
70
  },
65
71
  "dependencies": {
66
72
  "@nuxt/kit": "4.3.0"
@@ -106,6 +112,12 @@
106
112
  "vitest": "4.0.18",
107
113
  "vue-tsc": "3.2.4"
108
114
  },
115
+ "pnpm": {
116
+ "onlyBuiltDependencies": [
117
+ "@parcel/watcher",
118
+ "esbuild"
119
+ ]
120
+ },
109
121
  "keywords": [
110
122
  "nuxt",
111
123
  "nuxt-module",