@arsedizioni/ars-utils 20.0.10 → 20.0.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.
@@ -1031,7 +1031,7 @@ declare class ClipperDocumentMenuComponent implements OnInit, OnDestroy {
1031
1031
  private changeDetector;
1032
1032
  private clipperService;
1033
1033
  readonly useSelections: _angular_core.InputSignal<boolean>;
1034
- readonly selectionSource: _angular_core.InputSignal<"none" | "selection" | "bag">;
1034
+ readonly selectionSource: _angular_core.InputSignal<"selection" | "none" | "bag">;
1035
1035
  protected selection: () => ClipperDocumentInfo[];
1036
1036
  readonly parent: _angular_core.InputSignal<ClipperSearchResultManager>;
1037
1037
  readonly item: _angular_core.InputSignal<ClipperDocumentInfo>;
package/core/index.d.ts CHANGED
@@ -111,6 +111,13 @@ declare enum DateFormat {
111
111
  ShortUS = 11,// mm/dd/yyyy
112
112
  ShortISO8601 = 12
113
113
  }
114
+ interface PasswordStrength {
115
+ score: number;
116
+ label: string;
117
+ color: string;
118
+ suggestions: string[];
119
+ isValid: boolean;
120
+ }
114
121
  declare class SystemUtils {
115
122
  /**
116
123
  * Array find by key
@@ -314,6 +321,12 @@ declare class SystemUtils {
314
321
  * @returns : the password string
315
322
  */
316
323
  static generatePassword(): string;
324
+ /**
325
+ * Calculate password strength
326
+ * @param password: the password to evaluate
327
+ * @returns the password strength info
328
+ */
329
+ static calculatePasswordStrength(password: string): PasswordStrength;
317
330
  /**
318
331
  * Check if current browser supports touch
319
332
  * @returns : true if the display is touchable
@@ -915,4 +928,4 @@ declare class BroadcastChannelManager {
915
928
  }
916
929
 
917
930
  export { ArsCoreModule, ArsDateFnsModule, AutoFocusDirective, BroadcastChannelManager, BroadcastService, CopyClipboardDirective, DateFnsAdapter, DateFormat, DateInterval, DateIntervalChangeDirective, DeleteModel, EmailsValidatorDirective, EnvironmentService, EqualsValidatorDirective, FileInfo, FileSizeValidatorDirective, FormatHtmlPipe, FormatPipe, GroupModel, GuidValidatorDirective, IDModel, ImportModel, MAT_DATE_FNS_FORMATS, MaxTermsValidatorDirective, NotEqualValidatorDirective, NotFutureValidatorDirective, PasswordValidatorDirective, QueryModel, RelationModel, ReplacePipe, SafeHtmlPipe, SafeUrlPipe, ScreenService, SearchCallbackPipe, SearchFilterPipe, SelectableModel, SqlDateValidatorDirective, SystemUtils, ThemeService, TimeValidatorDirective, UpdateRelationsModel, UrlValidatorDirective, UtilsMessages, ValidIfDirective, ValidatorDirective, ValueModel };
918
- export type { AddModel, AddResultModel, ApiResponse, ApiResult, BroadcastChannelMessageBag, BroadcastChannelSubscriberInfo, BroadcastMessageInfo, Checkable, DeleteResultModel, DoneResult, EnableDisableModel, ErrorInfo, File, Folder, FolderTree, INode, LoginResult, NameValueItem, QueryResultModel, SearchBag, SearchFilterMetadata, Searchable, SendToModel, ThemeType, UpdateModel, UpdateResultModel, Validated };
931
+ export type { AddModel, AddResultModel, ApiResponse, ApiResult, BroadcastChannelMessageBag, BroadcastChannelSubscriberInfo, BroadcastMessageInfo, Checkable, DeleteResultModel, DoneResult, EnableDisableModel, ErrorInfo, File, Folder, FolderTree, INode, LoginResult, NameValueItem, PasswordStrength, QueryResultModel, SearchBag, SearchFilterMetadata, Searchable, SendToModel, ThemeType, UpdateModel, UpdateResultModel, Validated };
@@ -667,6 +667,89 @@ class SystemUtils {
667
667
  password = password.substring(0, 7) + "M";
668
668
  return password;
669
669
  }
670
+ /**
671
+ * Calculate password strength
672
+ * @param password: the password to evaluate
673
+ * @returns the password strength info
674
+ */
675
+ static calculatePasswordStrength(password) {
676
+ let score = 0;
677
+ const suggestions = [];
678
+ // Length
679
+ if (password.length >= 10)
680
+ score++;
681
+ else
682
+ suggestions.push('Usa almeno 10 caratteri');
683
+ if (password.length >= 12)
684
+ score++;
685
+ else if (password.length >= 10)
686
+ suggestions.push('Considera di usare più di 12 caratteri');
687
+ // Lowercase letters
688
+ if (/[a-z]/.test(password))
689
+ score++;
690
+ else
691
+ suggestions.push('Aggiungi lettere minuscole');
692
+ // Uppercase letters
693
+ if (/[A-Z]/.test(password))
694
+ score++;
695
+ else
696
+ suggestions.push('Aggiungi lettere maiuscole');
697
+ // Numbers
698
+ if (/\d/.test(password))
699
+ score++;
700
+ else
701
+ suggestions.push('Aggiungi numeri');
702
+ // Special characters
703
+ if (/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password))
704
+ score++;
705
+ else
706
+ suggestions.push('Aggiungi caratteri speciali (!@#$%^&*)');
707
+ // Common patterns
708
+ if (/(.)\1{2,}/.test(password)) {
709
+ score = Math.max(0, score - 1);
710
+ suggestions.push('Evita di ripetere lo stesso carattere');
711
+ }
712
+ if (/123|abc|qwe/i.test(password)) {
713
+ score = Math.max(0, score - 1);
714
+ suggestions.push('Evita sequenze comuni (123, abc, qwe)');
715
+ }
716
+ // Label and color
717
+ let label;
718
+ let color;
719
+ let isValid;
720
+ if (score <= 2) {
721
+ label = 'Molto debole';
722
+ color = '#f44336';
723
+ isValid = false;
724
+ }
725
+ else if (score <= 3) {
726
+ label = 'Debole';
727
+ color = '#ff9800';
728
+ isValid = false;
729
+ }
730
+ else if (score <= 4) {
731
+ label = 'Media';
732
+ color = '#ffc107';
733
+ isValid = true;
734
+ }
735
+ else if (score <= 5) {
736
+ label = 'Forte';
737
+ color = '#8bc34a';
738
+ isValid = true;
739
+ }
740
+ else {
741
+ label = 'Molto forte';
742
+ color = '#4caf50';
743
+ isValid = true;
744
+ }
745
+ return {
746
+ score: score,
747
+ label: label,
748
+ color: color,
749
+ suggestions: suggestions,
750
+ isValid
751
+ };
752
+ }
670
753
  /**
671
754
  * Check if current browser supports touch
672
755
  * @returns : true if the display is touchable
@@ -1254,21 +1337,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImpor
1254
1337
  }] });
1255
1338
  class PasswordValidatorDirective {
1256
1339
  validate(control) {
1257
- const input = control.value;
1258
- let isValid = input && input.length >= 8;
1259
- let hasUpperCase = false;
1260
- let hasSymbol = false;
1261
- if (isValid) {
1262
- for (let i = 0; i < input.length; i++) {
1263
- let ch = input[i];
1264
- if (ch == ch.toUpperCase())
1265
- hasUpperCase = true;
1266
- if ("$£$%&/()=?!*+-°^#@§[]{}<>_-:;.,".indexOf(ch) != -1)
1267
- hasSymbol = true;
1268
- }
1269
- isValid = hasSymbol && hasUpperCase;
1270
- }
1271
- if (!isValid) {
1340
+ const input = control.value ?? '';
1341
+ const strength = SystemUtils.calculatePasswordStrength(input);
1342
+ if (!strength.isValid) {
1272
1343
  return { password: "Non valido." };
1273
1344
  }
1274
1345
  else {