@lenne.tech/nuxt-extensions 1.0.0

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +339 -0
  3. package/dist/module.d.mts +10 -0
  4. package/dist/module.json +9 -0
  5. package/dist/module.mjs +126 -0
  6. package/dist/runtime/components/transition/LtTransitionFade.d.vue.ts +39 -0
  7. package/dist/runtime/components/transition/LtTransitionFade.vue +21 -0
  8. package/dist/runtime/components/transition/LtTransitionFade.vue.d.ts +39 -0
  9. package/dist/runtime/components/transition/LtTransitionFadeScale.d.vue.ts +42 -0
  10. package/dist/runtime/components/transition/LtTransitionFadeScale.vue +21 -0
  11. package/dist/runtime/components/transition/LtTransitionFadeScale.vue.d.ts +42 -0
  12. package/dist/runtime/components/transition/LtTransitionSlide.d.vue.ts +13 -0
  13. package/dist/runtime/components/transition/LtTransitionSlide.vue +16 -0
  14. package/dist/runtime/components/transition/LtTransitionSlide.vue.d.ts +13 -0
  15. package/dist/runtime/components/transition/LtTransitionSlideBottom.d.vue.ts +13 -0
  16. package/dist/runtime/components/transition/LtTransitionSlideBottom.vue +16 -0
  17. package/dist/runtime/components/transition/LtTransitionSlideBottom.vue.d.ts +13 -0
  18. package/dist/runtime/components/transition/LtTransitionSlideRevert.d.vue.ts +13 -0
  19. package/dist/runtime/components/transition/LtTransitionSlideRevert.vue +16 -0
  20. package/dist/runtime/components/transition/LtTransitionSlideRevert.vue.d.ts +13 -0
  21. package/dist/runtime/composables/auth/use-lt-auth.d.ts +32 -0
  22. package/dist/runtime/composables/auth/use-lt-auth.js +411 -0
  23. package/dist/runtime/composables/index.d.ts +5 -0
  24. package/dist/runtime/composables/index.js +5 -0
  25. package/dist/runtime/composables/use-lt-auth-client.d.ts +29 -0
  26. package/dist/runtime/composables/use-lt-auth-client.js +27 -0
  27. package/dist/runtime/composables/use-lt-file.d.ts +27 -0
  28. package/dist/runtime/composables/use-lt-file.js +60 -0
  29. package/dist/runtime/composables/use-lt-share.d.ts +32 -0
  30. package/dist/runtime/composables/use-lt-share.js +52 -0
  31. package/dist/runtime/composables/use-lt-tus-upload.d.ts +32 -0
  32. package/dist/runtime/composables/use-lt-tus-upload.js +236 -0
  33. package/dist/runtime/lib/auth-client.d.ts +831 -0
  34. package/dist/runtime/lib/auth-client.js +144 -0
  35. package/dist/runtime/lib/auth-state.d.ts +58 -0
  36. package/dist/runtime/lib/auth-state.js +131 -0
  37. package/dist/runtime/lib/index.d.ts +2 -0
  38. package/dist/runtime/lib/index.js +12 -0
  39. package/dist/runtime/locales/de.json +19 -0
  40. package/dist/runtime/locales/en.json +19 -0
  41. package/dist/runtime/plugins/auth-interceptor.client.d.ts +14 -0
  42. package/dist/runtime/plugins/auth-interceptor.client.js +88 -0
  43. package/dist/runtime/server/tsconfig.json +3 -0
  44. package/dist/runtime/types/auth.d.ts +127 -0
  45. package/dist/runtime/types/auth.js +0 -0
  46. package/dist/runtime/types/index.d.ts +3 -0
  47. package/dist/runtime/types/index.js +0 -0
  48. package/dist/runtime/types/module.d.ts +88 -0
  49. package/dist/runtime/types/module.js +0 -0
  50. package/dist/runtime/types/upload.d.ts +133 -0
  51. package/dist/runtime/types/upload.js +0 -0
  52. package/dist/runtime/utils/crypto.d.ts +40 -0
  53. package/dist/runtime/utils/crypto.js +17 -0
  54. package/dist/runtime/utils/index.d.ts +2 -0
  55. package/dist/runtime/utils/index.js +2 -0
  56. package/dist/runtime/utils/tw.d.ts +20 -0
  57. package/dist/runtime/utils/tw.js +1 -0
  58. package/dist/types.d.mts +9 -0
  59. package/package.json +99 -0
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Auth module configuration options
3
+ */
4
+ export interface LtAuthModuleOptions {
5
+ /** Auth API base path (default: '/iam' - must match nest-server betterAuth.basePath) */
6
+ basePath?: string;
7
+ /** API base URL (default: from env or http://localhost:3000) */
8
+ baseURL?: string;
9
+ /** Enable the auth module (default: true) */
10
+ enabled?: boolean;
11
+ /** Enable admin plugin (default: true) */
12
+ enableAdmin?: boolean;
13
+ /** Enable passkey plugin (default: true) */
14
+ enablePasskey?: boolean;
15
+ /** Enable 2FA plugin (default: true) */
16
+ enableTwoFactor?: boolean;
17
+ /** Auth interceptor configuration */
18
+ interceptor?: {
19
+ /** Enable the auth interceptor plugin (default: true) */
20
+ enabled?: boolean;
21
+ /** Paths that should not trigger auto-logout on 401 */
22
+ publicPaths?: string[];
23
+ };
24
+ /** Login page path for redirects (default: '/auth/login') */
25
+ loginPath?: string;
26
+ /** 2FA redirect path (default: '/auth/2fa') */
27
+ twoFactorRedirectPath?: string;
28
+ }
29
+ /**
30
+ * TUS upload module configuration options
31
+ */
32
+ export interface LtTusModuleOptions {
33
+ /** Default chunk size in bytes (default: 5MB) */
34
+ defaultChunkSize?: number;
35
+ /** Default TUS upload endpoint (default: '/files/upload') */
36
+ defaultEndpoint?: string;
37
+ }
38
+ /**
39
+ * i18n module configuration options
40
+ */
41
+ export interface LtI18nModuleOptions {
42
+ /** Automatically merge locale files with @nuxtjs/i18n (default: true) */
43
+ autoMerge?: boolean;
44
+ }
45
+ /**
46
+ * Main module options for @lenne.tech/nuxt-extensions
47
+ */
48
+ export interface LtExtensionsModuleOptions {
49
+ /** Auth module configuration */
50
+ auth?: LtAuthModuleOptions;
51
+ /** i18n configuration */
52
+ i18n?: LtI18nModuleOptions;
53
+ /** TUS upload module configuration */
54
+ tus?: LtTusModuleOptions;
55
+ }
56
+ /**
57
+ * Public runtime config added by this module
58
+ */
59
+ export interface LtExtensionsPublicRuntimeConfig {
60
+ ltExtensions: {
61
+ auth: {
62
+ basePath: string;
63
+ baseURL: string;
64
+ enabled: boolean;
65
+ enableAdmin: boolean;
66
+ enablePasskey: boolean;
67
+ enableTwoFactor: boolean;
68
+ interceptor: {
69
+ enabled: boolean;
70
+ publicPaths: string[];
71
+ };
72
+ loginPath: string;
73
+ twoFactorRedirectPath: string;
74
+ };
75
+ tus: {
76
+ defaultChunkSize: number;
77
+ defaultEndpoint: string;
78
+ };
79
+ };
80
+ }
81
+ declare module 'nuxt/schema' {
82
+ interface PublicRuntimeConfig extends LtExtensionsPublicRuntimeConfig {
83
+ }
84
+ }
85
+ declare module '@nuxt/schema' {
86
+ interface PublicRuntimeConfig extends LtExtensionsPublicRuntimeConfig {
87
+ }
88
+ }
File without changes
@@ -0,0 +1,133 @@
1
+ import type { ComputedRef } from 'vue';
2
+ /**
3
+ * Status of an upload item
4
+ */
5
+ export type LtUploadStatus = 'completed' | 'error' | 'idle' | 'paused' | 'uploading';
6
+ /**
7
+ * Progress information for an upload
8
+ */
9
+ export interface LtUploadProgress {
10
+ /** Total bytes to upload */
11
+ bytesTotal: number;
12
+ /** Bytes already uploaded */
13
+ bytesUploaded: number;
14
+ /** Percentage complete (0-100) */
15
+ percentage: number;
16
+ /** Estimated remaining time in seconds */
17
+ remainingTime: number;
18
+ /** Current upload speed in bytes/second */
19
+ speed: number;
20
+ }
21
+ /**
22
+ * Individual upload item with progress tracking
23
+ */
24
+ export interface LtUploadItem {
25
+ /** Timestamp when upload completed */
26
+ completedAt?: Date;
27
+ /** Error message if upload failed */
28
+ error?: string;
29
+ /** The file being uploaded */
30
+ file: File;
31
+ /** Unique identifier for this upload */
32
+ id: string;
33
+ /** Custom metadata to include with the upload */
34
+ metadata?: Record<string, string>;
35
+ /** Current progress information */
36
+ progress: LtUploadProgress;
37
+ /** Timestamp when upload started */
38
+ startedAt?: Date;
39
+ /** Current status of the upload */
40
+ status: LtUploadStatus;
41
+ /** URL of the uploaded file (available after completion) */
42
+ url?: string;
43
+ }
44
+ /**
45
+ * Configuration options for TUS uploads
46
+ */
47
+ export interface LtUploadOptions {
48
+ /** Automatically start uploads when files are added (default: true) */
49
+ autoStart?: boolean;
50
+ /** Chunk size in bytes (default: 5MB) */
51
+ chunkSize?: number;
52
+ /** TUS upload endpoint URL */
53
+ endpoint?: string;
54
+ /** Additional headers to include with requests */
55
+ headers?: Record<string, string>;
56
+ /** Default metadata to include with all uploads */
57
+ metadata?: Record<string, string>;
58
+ /** Callback when an upload fails */
59
+ onError?: (item: LtUploadItem, error: Error) => void;
60
+ /** Callback when upload progress updates */
61
+ onProgress?: (item: LtUploadItem) => void;
62
+ /** Callback when an upload completes successfully */
63
+ onSuccess?: (item: LtUploadItem) => void;
64
+ /** Maximum number of concurrent uploads (default: 3) */
65
+ parallelUploads?: number;
66
+ /** Retry delays in milliseconds (default: [0, 1000, 3000, 5000, 10000]) */
67
+ retryDelays?: number[];
68
+ }
69
+ /**
70
+ * Return type for useLtTusUpload composable
71
+ */
72
+ export interface UseLtTusUploadReturn {
73
+ /** Add files to the upload queue, returns array of upload IDs */
74
+ addFiles: (files: File | File[]) => Promise<string[]>;
75
+ /** Cancel all uploads */
76
+ cancelAll: () => void;
77
+ /** Cancel a specific upload by ID */
78
+ cancelUpload: (id: string) => void;
79
+ /** Remove all completed uploads from the list */
80
+ clearCompleted: () => void;
81
+ /** Get an upload item by ID */
82
+ getUpload: (id: string) => LtUploadItem | undefined;
83
+ /** Pause all active uploads */
84
+ pauseAll: () => void;
85
+ /** Pause a specific upload by ID */
86
+ pauseUpload: (id: string) => void;
87
+ /** Remove an upload from the list (also cancels if active) */
88
+ removeUpload: (id: string) => void;
89
+ /** Resume all paused uploads */
90
+ resumeAll: () => void;
91
+ /** Resume a specific upload by ID */
92
+ resumeUpload: (id: string) => void;
93
+ /** Retry a failed upload by ID */
94
+ retryUpload: (id: string) => void;
95
+ /** Start all idle uploads */
96
+ startAll: () => void;
97
+ /** Start a specific upload by ID */
98
+ startUpload: (id: string) => void;
99
+ /** Whether any uploads are currently in progress */
100
+ isUploading: ComputedRef<boolean>;
101
+ /** Aggregated progress of all uploads */
102
+ totalProgress: ComputedRef<LtUploadProgress>;
103
+ /** List of all upload items */
104
+ uploads: ComputedRef<LtUploadItem[]>;
105
+ }
106
+ /**
107
+ * File info returned from the server
108
+ */
109
+ export interface LtFileInfo {
110
+ [key: string]: unknown;
111
+ filename: string;
112
+ id: string;
113
+ mimetype: string;
114
+ size: number;
115
+ url?: string;
116
+ }
117
+ /**
118
+ * Return type for useLtFile composable
119
+ */
120
+ export interface UseLtFileReturn {
121
+ /** Format duration in seconds to human readable string */
122
+ formatDuration: (seconds: number) => string;
123
+ /** Format bytes to human readable string (e.g., "1.5 MB") */
124
+ formatFileSize: (bytes: number) => string;
125
+ /** Get download URL for a file by ID */
126
+ getDownloadUrl: (id: string, filename?: string) => string;
127
+ /** Get file info from the server by ID */
128
+ getFileInfo: (id: string | undefined) => Promise<LtFileInfo | null | string>;
129
+ /** Get direct file URL by ID */
130
+ getFileUrl: (id: string) => string;
131
+ /** Check if a string is a valid MongoDB ObjectId */
132
+ isValidMongoID: (id: string) => boolean;
133
+ }
File without changes
@@ -0,0 +1,40 @@
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
+ * @example
9
+ * ```typescript
10
+ * const hash = await ltSha256('myPassword');
11
+ * // Returns: 'a5de7...9f' (64 character hex string)
12
+ * ```
13
+ */
14
+ export declare function ltSha256(message: string): Promise<string>;
15
+ /**
16
+ * Converts an ArrayBuffer to a base64url-encoded string
17
+ * Used for WebAuthn credential responses
18
+ *
19
+ * @param buffer - The ArrayBuffer to convert
20
+ * @returns The base64url-encoded string (no padding)
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * const base64 = ltArrayBufferToBase64Url(credential.rawId);
25
+ * ```
26
+ */
27
+ export declare function ltArrayBufferToBase64Url(buffer: ArrayBuffer): string;
28
+ /**
29
+ * Converts a base64url-encoded string to a Uint8Array
30
+ * Used for WebAuthn challenge decoding
31
+ *
32
+ * @param base64url - The base64url-encoded string
33
+ * @returns The decoded Uint8Array
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const challenge = ltBase64UrlToUint8Array(options.challenge);
38
+ * ```
39
+ */
40
+ export declare function ltBase64UrlToUint8Array(base64url: string): Uint8Array;
@@ -0,0 +1,17 @@
1
+ export async function ltSha256(message) {
2
+ const msgBuffer = new TextEncoder().encode(message);
3
+ const hashBuffer = await crypto.subtle.digest("SHA-256", msgBuffer);
4
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
5
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
6
+ }
7
+ export function ltArrayBufferToBase64Url(buffer) {
8
+ const bytes = new Uint8Array(buffer);
9
+ let binary = "";
10
+ bytes.forEach((b) => binary += String.fromCharCode(b));
11
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
12
+ }
13
+ export function ltBase64UrlToUint8Array(base64url) {
14
+ const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
15
+ const paddedBase64 = base64 + "=".repeat((4 - base64.length % 4) % 4);
16
+ return Uint8Array.from(atob(paddedBase64), (c) => c.charCodeAt(0));
17
+ }
@@ -0,0 +1,2 @@
1
+ export { ltArrayBufferToBase64Url, ltBase64UrlToUint8Array, ltSha256 } from './crypto.js';
2
+ export { tw } from './tw.js';
@@ -0,0 +1,2 @@
1
+ export { ltArrayBufferToBase64Url, ltBase64UrlToUint8Array, ltSha256 } from "./crypto.js";
2
+ export { tw } from "./tw.js";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Tailwind TypeScript helper
3
+ *
4
+ * This utility function helps with TypeScript autocomplete when using
5
+ * Tailwind CSS classes as string literals. It's a no-op at runtime but
6
+ * provides type information for IDE support.
7
+ *
8
+ * @param tailwindClasses - A string or template literal with Tailwind classes
9
+ * @returns The same string unchanged
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // With IDE plugins, you get autocomplete for Tailwind classes
14
+ * const buttonClasses = tw`bg-blue-500 hover:bg-blue-700 text-white`;
15
+ *
16
+ * // Also works as a regular function
17
+ * const classes = tw('flex items-center gap-2');
18
+ * ```
19
+ */
20
+ export declare const tw: <T extends string | TemplateStringsArray>(tailwindClasses: T) => T;
@@ -0,0 +1 @@
1
+ export const tw = (tailwindClasses) => tailwindClasses;
@@ -0,0 +1,9 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.mjs'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { type LtExtensionsModuleOptions } from '../dist/runtime/types/index.js'
8
+
9
+ export { type configKey, default, type name, type version } from './module.mjs'
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@lenne.tech/nuxt-extensions",
3
+ "version": "1.0.0",
4
+ "description": "Reusable Nuxt 4 composables, components, and Better-Auth integration for lenne.tech projects",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/lenneTech/nuxt-extensions.git"
8
+ },
9
+ "homepage": "https://github.com/lenneTech/nuxt-extensions#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/lenneTech/nuxt-extensions/issues"
12
+ },
13
+ "author": "lenne.Tech <info@lenne.tech> (https://lenne.tech)",
14
+ "license": "MIT",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/types.d.mts",
19
+ "import": "./dist/module.mjs"
20
+ }
21
+ },
22
+ "main": "./dist/module.mjs",
23
+ "typesVersions": {
24
+ "*": {
25
+ ".": [
26
+ "./dist/types.d.mts"
27
+ ]
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "prepare": "git config core.hooksPath .githooks",
35
+ "prepack": "nuxt-module-build build",
36
+ "dev": "npm run dev:prepare && nuxt dev playground",
37
+ "dev:build": "nuxt build playground",
38
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
39
+ "build": "nuxt-module-build build",
40
+ "lint": "oxlint src/",
41
+ "lint:fix": "oxlint --fix src/",
42
+ "test": "vitest run",
43
+ "test:watch": "vitest watch",
44
+ "test:coverage": "vitest run --coverage",
45
+ "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
46
+ "release": "npm run lint && npm run test && npm run prepack"
47
+ },
48
+ "dependencies": {
49
+ "@nuxt/kit": "4.2.2"
50
+ },
51
+ "peerDependencies": {
52
+ "@better-auth/passkey": ">=1.0.0",
53
+ "better-auth": ">=1.0.0",
54
+ "nuxt": ">=3.0.0",
55
+ "tus-js-client": ">=4.0.0"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "better-auth": {
59
+ "optional": false
60
+ },
61
+ "@better-auth/passkey": {
62
+ "optional": true
63
+ },
64
+ "tus-js-client": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "devDependencies": {
69
+ "@better-auth/passkey": "1.4.10",
70
+ "@nuxt/devtools": "3.1.1",
71
+ "@nuxt/module-builder": "1.0.2",
72
+ "@nuxt/schema": "4.2.2",
73
+ "@nuxt/test-utils": "3.23.0",
74
+ "@types/node": "25.0.10",
75
+ "@vitest/coverage-v8": "3.0.0",
76
+ "@vue/test-utils": "2.4.6",
77
+ "better-auth": "1.4.10",
78
+ "happy-dom": "20.3.7",
79
+ "nuxt": "4.2.2",
80
+ "oxlint": "0.17.0",
81
+ "tus-js-client": "4.3.1",
82
+ "typescript": "5.9.3",
83
+ "vitest": "4.0.17",
84
+ "vue-tsc": "3.2.2"
85
+ },
86
+ "keywords": [
87
+ "nuxt",
88
+ "nuxt-module",
89
+ "nuxt4",
90
+ "vue3",
91
+ "better-auth",
92
+ "authentication",
93
+ "passkey",
94
+ "webauthn",
95
+ "tus-upload",
96
+ "file-upload",
97
+ "lenne-tech"
98
+ ]
99
+ }