nuxt-users 1.4.0 → 1.5.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 (29) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/cli.mjs +12 -30
  3. package/dist/module.d.mts +1 -1
  4. package/dist/module.d.ts +1 -1
  5. package/dist/module.json +1 -1
  6. package/dist/module.mjs +37 -0
  7. package/dist/runtime/components/LoginForm.vue.d.ts +3 -3
  8. package/dist/runtime/components/PasswordStrengthIndicator.vue +132 -0
  9. package/dist/runtime/components/PasswordStrengthIndicator.vue.d.ts +12 -0
  10. package/dist/runtime/components/ProfileForm.vue +240 -0
  11. package/dist/runtime/components/ProfileForm.vue.d.ts +20 -0
  12. package/dist/runtime/components/ResetPasswordForm.vue +30 -4
  13. package/dist/runtime/composables/useAuth.d.ts +20 -2
  14. package/dist/runtime/composables/useAuth.js +53 -2
  15. package/dist/runtime/composables/usePasswordValidation.d.ts +33 -0
  16. package/dist/runtime/composables/usePasswordValidation.js +37 -0
  17. package/dist/runtime/plugin.js +29 -1
  18. package/dist/runtime/server/api/auth/reset-password.post.js +9 -3
  19. package/dist/runtime/server/api/profile/update-password.post.d.ts +4 -0
  20. package/dist/runtime/server/api/profile/update-password.post.js +60 -0
  21. package/dist/runtime/server/api/profile.get.d.ts +11 -0
  22. package/dist/runtime/server/api/profile.get.js +23 -0
  23. package/dist/shared/{nuxt-users.DZkU2AbH.mjs → nuxt-users.37k1R3_g.mjs} +172 -1
  24. package/dist/shared/{nuxt-users.DGRKT2Tq.d.mts → nuxt-users.CMEtv_Mw.d.mts} +64 -6
  25. package/dist/shared/{nuxt-users.DGRKT2Tq.d.ts → nuxt-users.CMEtv_Mw.d.ts} +64 -6
  26. package/dist/utils.d.mts +28 -2
  27. package/dist/utils.d.ts +28 -2
  28. package/dist/utils.mjs +1 -1
  29. package/package.json +3 -2
@@ -7,16 +7,16 @@ type DatabaseConfig = {
7
7
  password?: string;
8
8
  database?: string;
9
9
  };
10
- interface ModuleOptions {
10
+ interface RuntimeModuleOptions {
11
11
  connector?: {
12
12
  name: DatabaseType;
13
13
  options: DatabaseConfig;
14
14
  };
15
- tables: {
16
- migrations: string;
17
- users: string;
18
- personalAccessTokens: string;
19
- passwordResetTokens: string;
15
+ tables?: {
16
+ migrations?: string;
17
+ users?: string;
18
+ personalAccessTokens?: string;
19
+ passwordResetTokens?: string;
20
20
  };
21
21
  /**
22
22
  * Mailer configuration options for sending emails (e.g., password resets)
@@ -38,8 +38,66 @@ interface ModuleOptions {
38
38
  * @default ['/login']
39
39
  * @example ['/login', '/register']
40
40
  */
41
+ whitelist?: string[];
42
+ };
43
+ /**
44
+ * Password validation configuration
45
+ */
46
+ passwordValidation?: {
47
+ /**
48
+ * Minimum password length
49
+ * @default 8
50
+ */
51
+ minLength?: number;
52
+ /**
53
+ * Require uppercase letters
54
+ * @default true
55
+ */
56
+ requireUppercase?: boolean;
57
+ /**
58
+ * Require lowercase letters
59
+ * @default true
60
+ */
61
+ requireLowercase?: boolean;
62
+ /**
63
+ * Require numbers
64
+ * @default true
65
+ */
66
+ requireNumbers?: boolean;
67
+ /**
68
+ * Require special characters
69
+ * @default true
70
+ */
71
+ requireSpecialChars?: boolean;
72
+ /**
73
+ * Prevent common passwords
74
+ * @default true
75
+ */
76
+ preventCommonPasswords?: boolean;
77
+ };
78
+ }
79
+ interface ModuleOptions extends Omit<RuntimeModuleOptions, 'tables' | 'auth' | 'passwordValidation'> {
80
+ connector: {
81
+ name: DatabaseType;
82
+ options: DatabaseConfig;
83
+ };
84
+ tables: {
85
+ migrations: string;
86
+ users: string;
87
+ personalAccessTokens: string;
88
+ passwordResetTokens: string;
89
+ };
90
+ auth: {
41
91
  whitelist: string[];
42
92
  };
93
+ passwordValidation: {
94
+ minLength: number;
95
+ requireUppercase: boolean;
96
+ requireLowercase: boolean;
97
+ requireNumbers: boolean;
98
+ requireSpecialChars: boolean;
99
+ preventCommonPasswords: boolean;
100
+ };
43
101
  }
44
102
  interface MailerOptions {
45
103
  host: string;
@@ -7,16 +7,16 @@ type DatabaseConfig = {
7
7
  password?: string;
8
8
  database?: string;
9
9
  };
10
- interface ModuleOptions {
10
+ interface RuntimeModuleOptions {
11
11
  connector?: {
12
12
  name: DatabaseType;
13
13
  options: DatabaseConfig;
14
14
  };
15
- tables: {
16
- migrations: string;
17
- users: string;
18
- personalAccessTokens: string;
19
- passwordResetTokens: string;
15
+ tables?: {
16
+ migrations?: string;
17
+ users?: string;
18
+ personalAccessTokens?: string;
19
+ passwordResetTokens?: string;
20
20
  };
21
21
  /**
22
22
  * Mailer configuration options for sending emails (e.g., password resets)
@@ -38,8 +38,66 @@ interface ModuleOptions {
38
38
  * @default ['/login']
39
39
  * @example ['/login', '/register']
40
40
  */
41
+ whitelist?: string[];
42
+ };
43
+ /**
44
+ * Password validation configuration
45
+ */
46
+ passwordValidation?: {
47
+ /**
48
+ * Minimum password length
49
+ * @default 8
50
+ */
51
+ minLength?: number;
52
+ /**
53
+ * Require uppercase letters
54
+ * @default true
55
+ */
56
+ requireUppercase?: boolean;
57
+ /**
58
+ * Require lowercase letters
59
+ * @default true
60
+ */
61
+ requireLowercase?: boolean;
62
+ /**
63
+ * Require numbers
64
+ * @default true
65
+ */
66
+ requireNumbers?: boolean;
67
+ /**
68
+ * Require special characters
69
+ * @default true
70
+ */
71
+ requireSpecialChars?: boolean;
72
+ /**
73
+ * Prevent common passwords
74
+ * @default true
75
+ */
76
+ preventCommonPasswords?: boolean;
77
+ };
78
+ }
79
+ interface ModuleOptions extends Omit<RuntimeModuleOptions, 'tables' | 'auth' | 'passwordValidation'> {
80
+ connector: {
81
+ name: DatabaseType;
82
+ options: DatabaseConfig;
83
+ };
84
+ tables: {
85
+ migrations: string;
86
+ users: string;
87
+ personalAccessTokens: string;
88
+ passwordResetTokens: string;
89
+ };
90
+ auth: {
41
91
  whitelist: string[];
42
92
  };
93
+ passwordValidation: {
94
+ minLength: number;
95
+ requireUppercase: boolean;
96
+ requireLowercase: boolean;
97
+ requireNumbers: boolean;
98
+ requireSpecialChars: boolean;
99
+ preventCommonPasswords: boolean;
100
+ };
43
101
  }
44
102
  interface MailerOptions {
45
103
  host: string;
package/dist/utils.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as db0 from 'db0';
2
- import { M as ModuleOptions, U as User } from './shared/nuxt-users.DGRKT2Tq.mjs';
2
+ import { M as ModuleOptions, U as User } from './shared/nuxt-users.CMEtv_Mw.mjs';
3
3
 
4
4
  declare const useDb: (options: ModuleOptions) => Promise<db0.Database<db0.Connector<Database.Database>>>;
5
5
  declare const checkTableExists: (options: ModuleOptions, tableName: string) => Promise<boolean>;
@@ -35,4 +35,30 @@ declare const createMigrationsTable: (options: ModuleOptions) => Promise<void>;
35
35
 
36
36
  declare const runMigrations: (options: ModuleOptions) => Promise<void>;
37
37
 
38
- export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, runMigrations, updateUserPassword, useDb };
38
+ interface PasswordValidationResult {
39
+ isValid: boolean;
40
+ errors: string[];
41
+ strength: 'weak' | 'medium' | 'strong';
42
+ score: number;
43
+ hints: string[];
44
+ }
45
+ interface PasswordValidationOptions {
46
+ minLength?: number;
47
+ requireUppercase?: boolean;
48
+ requireLowercase?: boolean;
49
+ requireNumbers?: boolean;
50
+ requireSpecialChars?: boolean;
51
+ preventCommonPasswords?: boolean;
52
+ }
53
+ /**
54
+ * Get password validation options from module configuration
55
+ */
56
+ declare const getPasswordValidationOptions: (moduleOptions?: {
57
+ passwordValidation?: PasswordValidationOptions;
58
+ }) => PasswordValidationOptions;
59
+ declare const validatePassword: (password: string, options?: PasswordValidationOptions) => PasswordValidationResult;
60
+ declare const getPasswordStrengthColor: (strength: "weak" | "medium" | "strong") => string;
61
+ declare const getPasswordStrengthText: (strength: "weak" | "medium" | "strong") => string;
62
+
63
+ export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, getPasswordStrengthColor, getPasswordStrengthText, getPasswordValidationOptions, runMigrations, updateUserPassword, useDb, validatePassword };
64
+ export type { PasswordValidationOptions, PasswordValidationResult };
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as db0 from 'db0';
2
- import { M as ModuleOptions, U as User } from './shared/nuxt-users.DGRKT2Tq.js';
2
+ import { M as ModuleOptions, U as User } from './shared/nuxt-users.CMEtv_Mw.js';
3
3
 
4
4
  declare const useDb: (options: ModuleOptions) => Promise<db0.Database<db0.Connector<Database.Database>>>;
5
5
  declare const checkTableExists: (options: ModuleOptions, tableName: string) => Promise<boolean>;
@@ -35,4 +35,30 @@ declare const createMigrationsTable: (options: ModuleOptions) => Promise<void>;
35
35
 
36
36
  declare const runMigrations: (options: ModuleOptions) => Promise<void>;
37
37
 
38
- export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, runMigrations, updateUserPassword, useDb };
38
+ interface PasswordValidationResult {
39
+ isValid: boolean;
40
+ errors: string[];
41
+ strength: 'weak' | 'medium' | 'strong';
42
+ score: number;
43
+ hints: string[];
44
+ }
45
+ interface PasswordValidationOptions {
46
+ minLength?: number;
47
+ requireUppercase?: boolean;
48
+ requireLowercase?: boolean;
49
+ requireNumbers?: boolean;
50
+ requireSpecialChars?: boolean;
51
+ preventCommonPasswords?: boolean;
52
+ }
53
+ /**
54
+ * Get password validation options from module configuration
55
+ */
56
+ declare const getPasswordValidationOptions: (moduleOptions?: {
57
+ passwordValidation?: PasswordValidationOptions;
58
+ }) => PasswordValidationOptions;
59
+ declare const validatePassword: (password: string, options?: PasswordValidationOptions) => PasswordValidationResult;
60
+ declare const getPasswordStrengthColor: (strength: "weak" | "medium" | "strong") => string;
61
+ declare const getPasswordStrengthText: (strength: "weak" | "medium" | "strong") => string;
62
+
63
+ export { checkTableExists, createMigrationsTable, createPasswordResetTokensTable, createPersonalAccessTokensTable, createUser, createUsersTable, findUserByEmail, getPasswordStrengthColor, getPasswordStrengthText, getPasswordValidationOptions, runMigrations, updateUserPassword, useDb, validatePassword };
64
+ export type { PasswordValidationOptions, PasswordValidationResult };
package/dist/utils.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { c as checkTableExists, h as createMigrationsTable, g as createPasswordResetTokensTable, e as createPersonalAccessTokensTable, a as createUser, d as createUsersTable, f as findUserByEmail, r as runMigrations, b as updateUserPassword, u as useDb } from './shared/nuxt-users.DZkU2AbH.mjs';
1
+ export { c as checkTableExists, h as createMigrationsTable, g as createPasswordResetTokensTable, e as createPersonalAccessTokensTable, a as createUser, d as createUsersTable, f as findUserByEmail, j as getPasswordStrengthColor, k as getPasswordStrengthText, i as getPasswordValidationOptions, r as runMigrations, b as updateUserPassword, u as useDb, v as validatePassword } from './shared/nuxt-users.37k1R3_g.mjs';
2
2
  import 'bcrypt';
3
3
  import 'db0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-users",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "A comprehensive user management module for Nuxt 3 applications with authentication, database support, and CLI tools",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -64,8 +64,9 @@
64
64
  "lint": "eslint .",
65
65
  "lint:fix": "eslint . --fix",
66
66
  "pretest": "node -v | grep -q 'v22' || (echo 'Please use Node.js v22 for testing' && exit 1)",
67
- "test": "yarn test:types && yarn test:sqlite && yarn test:mysql && yarn test:postgresql",
67
+ "test": "yarn test:types && yarn test:unit && yarn test:sqlite && yarn test:mysql && yarn test:postgresql",
68
68
  "test:watch": "vitest watch",
69
+ "test:unit": "./scripts/test-unit.sh",
69
70
  "test:sqlite": "./scripts/test-sqlite.sh",
70
71
  "test:mysql": "./scripts/test-mysql.sh",
71
72
  "test:postgresql": "./scripts/test-postgresql.sh",