nuxt-users 1.11.0 → 1.13.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 (44) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +27 -59
  3. package/dist/cli.mjs +2 -3
  4. package/dist/module.d.mts +1 -1
  5. package/dist/module.d.ts +1 -1
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +35 -9
  8. package/dist/runtime/assets/nuxt-users.css +1 -0
  9. package/dist/runtime/components/NUsersList.vue +136 -0
  10. package/dist/runtime/components/NUsersList.vue.d.ts +74 -0
  11. package/dist/runtime/components/{LoginForm.vue → NUsersLoginForm.vue} +20 -23
  12. package/dist/runtime/components/{LoginForm.vue.d.ts → NUsersLoginForm.vue.d.ts} +5 -9
  13. package/dist/runtime/components/{LogoutLink.vue → NUsersLogoutLink.vue} +2 -6
  14. package/dist/runtime/components/{PasswordStrengthIndicator.vue → NUsersPasswordStrengthIndicator.vue} +18 -22
  15. package/dist/runtime/components/{ProfileInfo.vue → NUsersProfileInfo.vue} +5 -7
  16. package/dist/runtime/components/{ResetPasswordForm.vue → NUsersResetPasswordForm.vue} +22 -26
  17. package/dist/runtime/components/{ResetPasswordForm.vue.d.ts → NUsersResetPasswordForm.vue.d.ts} +3 -6
  18. package/dist/runtime/components/NUsersUserCard.vue +93 -0
  19. package/dist/runtime/components/NUsersUserCard.vue.d.ts +33 -0
  20. package/dist/runtime/components/NUsersUserForm.vue +141 -0
  21. package/dist/runtime/components/NUsersUserForm.vue.d.ts +12 -0
  22. package/dist/runtime/composables/useAuthentication.d.ts +2 -0
  23. package/dist/runtime/composables/usePasswordValidation.d.ts +2 -2
  24. package/dist/runtime/middleware/authorization.client.js +1 -1
  25. package/dist/runtime/server/api/nuxt-users/index.get.d.ts +20 -0
  26. package/dist/runtime/server/api/nuxt-users/index.get.js +58 -0
  27. package/dist/runtime/server/api/nuxt-users/me.patch.d.ts +4 -0
  28. package/dist/runtime/server/api/nuxt-users/me.patch.js +33 -0
  29. package/dist/runtime/server/api/nuxt-users/session/index.post.d.ts +1 -0
  30. package/dist/runtime/server/middleware/authorization.server.js +24 -9
  31. package/dist/runtime/server/utils/user.js +20 -18
  32. package/dist/runtime/utils/permissions.d.ts +5 -3
  33. package/dist/runtime/utils/permissions.js +20 -4
  34. package/dist/shared/{nuxt-users.C7T1DKBV.d.ts → nuxt-users.u7N4meyI.d.mts} +8 -2
  35. package/dist/shared/{nuxt-users.C7T1DKBV.d.mts → nuxt-users.u7N4meyI.d.ts} +8 -2
  36. package/dist/utils.d.mts +1 -2
  37. package/dist/utils.d.ts +1 -2
  38. package/dist/utils.mjs +162 -2
  39. package/package.json +1 -1
  40. package/dist/runtime/assets/colors.css +0 -1
  41. package/dist/shared/nuxt-users.BnOQs2LI.mjs +0 -162
  42. package/dist/runtime/components/{LogoutLink.vue.d.ts → NUsersLogoutLink.vue.d.ts} +4 -4
  43. /package/dist/runtime/components/{PasswordStrengthIndicator.vue.d.ts → NUsersPasswordStrengthIndicator.vue.d.ts} +0 -0
  44. /package/dist/runtime/components/{ProfileInfo.vue.d.ts → NUsersProfileInfo.vue.d.ts} +0 -0
@@ -1,162 +0,0 @@
1
- const DEFAULT_OPTIONS = {
2
- minLength: 8,
3
- requireUppercase: true,
4
- requireLowercase: true,
5
- requireNumbers: true,
6
- requireSpecialChars: true,
7
- preventCommonPasswords: true
8
- };
9
- const getPasswordValidationOptions = (moduleOptions) => {
10
- if (!moduleOptions?.passwordValidation) {
11
- return DEFAULT_OPTIONS;
12
- }
13
- return {
14
- ...DEFAULT_OPTIONS,
15
- ...moduleOptions.passwordValidation
16
- };
17
- };
18
- const COMMON_PASSWORDS = [
19
- "password",
20
- "123456",
21
- "123456789",
22
- "qwerty",
23
- "abc123",
24
- "password123",
25
- "admin",
26
- "letmein",
27
- "welcome",
28
- "monkey",
29
- "dragon",
30
- "master",
31
- "hello",
32
- "freedom",
33
- "whatever",
34
- "qazwsx",
35
- "trustno1",
36
- "jordan",
37
- "harley",
38
- "ranger",
39
- "buster",
40
- "thomas",
41
- "tigger",
42
- "robert",
43
- "soccer",
44
- "batman",
45
- "test",
46
- "pass",
47
- "user",
48
- "guest",
49
- "login",
50
- "secret",
51
- "god",
52
- "love",
53
- "sex",
54
- "money",
55
- "password1",
56
- "12345678",
57
- "qwerty123",
58
- "admin123",
59
- "password!",
60
- "password1!",
61
- "password123",
62
- "password123!"
63
- ];
64
- const validatePassword = (password, options = {}) => {
65
- const config = { ...DEFAULT_OPTIONS, ...options };
66
- const errors = [];
67
- const hints = [];
68
- let score = 0;
69
- if (password.length < config.minLength) {
70
- errors.push(`Password must be at least ${config.minLength} characters long`);
71
- hints.push(`Use at least ${config.minLength} characters`);
72
- } else {
73
- score += 20;
74
- if (password.length < 12) {
75
- hints.push("Use 12 or more characters for extra security");
76
- }
77
- }
78
- if (config.requireUppercase && !/[A-Z]/.test(password)) {
79
- errors.push("Password must contain at least one uppercase letter");
80
- hints.push("Add an uppercase letter (A-Z)");
81
- } else if (/[A-Z]/.test(password)) {
82
- score += 15;
83
- }
84
- if (config.requireLowercase && !/[a-z]/.test(password)) {
85
- errors.push("Password must contain at least one lowercase letter");
86
- hints.push("Add a lowercase letter (a-z)");
87
- } else if (/[a-z]/.test(password)) {
88
- score += 15;
89
- }
90
- if (config.requireNumbers && !/\d/.test(password)) {
91
- errors.push("Password must contain at least one number");
92
- hints.push("Add a number (0-9)");
93
- } else if (/\d/.test(password)) {
94
- score += 15;
95
- }
96
- if (config.requireSpecialChars && !/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)) {
97
- errors.push("Password must contain at least one special character");
98
- hints.push("Add a special character (e.g. !@#$%)");
99
- } else if (/[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password)) {
100
- score += 15;
101
- }
102
- if (config.preventCommonPasswords && COMMON_PASSWORDS.includes(password.toLowerCase())) {
103
- errors.push("Password is too common. Please choose a more unique password");
104
- hints.push("Avoid common passwords or names");
105
- }
106
- if (password.length >= 12) {
107
- score += 10;
108
- } else if (password.length >= 10) {
109
- score += 5;
110
- }
111
- const hasUppercase = /[A-Z]/.test(password);
112
- const hasLowercase = /[a-z]/.test(password);
113
- const hasNumbers = /\d/.test(password);
114
- const hasSpecial = /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(password);
115
- const complexityTypes = [hasUppercase, hasLowercase, hasNumbers, hasSpecial].filter(Boolean).length;
116
- if (complexityTypes >= 4) {
117
- score += 10;
118
- } else if (complexityTypes >= 3) {
119
- score += 5;
120
- hints.push("Use a mix of uppercase, lowercase, numbers, and special characters");
121
- }
122
- let strength = "weak";
123
- if (score >= 80) {
124
- strength = "strong";
125
- } else if (score >= 60) {
126
- strength = "medium";
127
- }
128
- return {
129
- isValid: errors.length === 0,
130
- errors,
131
- strength,
132
- score: Math.min(score, 100),
133
- hints: Array.from(new Set(hints))
134
- // deduplicate
135
- };
136
- };
137
- const getPasswordStrengthColor = (strength) => {
138
- switch (strength) {
139
- case "weak":
140
- return "#dc3545";
141
- case "medium":
142
- return "#ffc107";
143
- case "strong":
144
- return "#28a745";
145
- default:
146
- return "#6c757d";
147
- }
148
- };
149
- const getPasswordStrengthText = (strength) => {
150
- switch (strength) {
151
- case "weak":
152
- return "Weak";
153
- case "medium":
154
- return "Medium";
155
- case "strong":
156
- return "Strong";
157
- default:
158
- return "Unknown";
159
- }
160
- };
161
-
162
- export { getPasswordStrengthColor as a, getPasswordStrengthText as b, getPasswordValidationOptions as g, validatePassword as v };
@@ -16,13 +16,13 @@ type __VLS_Slots = {} & {
16
16
  default?: (props: typeof __VLS_1) => any;
17
17
  };
18
18
  declare const __VLS_component: import("vue").DefineComponent<LogoutLinkProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
19
- success: () => any;
20
- error: (error: string) => any;
21
19
  click: () => any;
20
+ error: (error: string) => any;
21
+ success: () => any;
22
22
  }, string, import("vue").PublicProps, Readonly<LogoutLinkProps> & Readonly<{
23
- onSuccess?: (() => any) | undefined;
24
- onError?: ((error: string) => any) | undefined;
25
23
  onClick?: (() => any) | undefined;
24
+ onError?: ((error: string) => any) | undefined;
25
+ onSuccess?: (() => any) | undefined;
26
26
  }>, {
27
27
  redirectTo: string;
28
28
  linkText: string;