@arsedizioni/ars-utils 20.2.34 → 20.3.1

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.
@@ -1009,7 +1009,6 @@ declare class ClipperService implements OnDestroy {
1009
1009
  readonly loggingIn: _angular_core.WritableSignal<boolean>;
1010
1010
  readonly snapshot: _angular_core.WritableSignal<ClipperSearchResult>;
1011
1011
  readonly supportsRS: _angular_core.WritableSignal<boolean>;
1012
- readonly shouldRefreshToken: _angular_core.WritableSignal<boolean>;
1013
1012
  readonly referencesSnapshot: _angular_core.WritableSignal<ClipperSearchResult>;
1014
1013
  readonly dashboard: ClipperDashboard;
1015
1014
  readonly bag: _angular_core.WritableSignal<ClipperDocumentInfo[]>;
@@ -1035,10 +1034,6 @@ declare class ClipperService implements OnDestroy {
1035
1034
  * Get access token expiration date
1036
1035
  */
1037
1036
  private getTokenExpirationDate;
1038
- /**
1039
- * Checks if access token in expired
1040
- */
1041
- isTokenExpired(): boolean;
1042
1037
  /**
1043
1038
  * Set keep alive
1044
1039
  */
@@ -1039,7 +1039,7 @@ declare class ClipperDocumentMenuComponent implements OnInit, OnDestroy {
1039
1039
  private changeDetector;
1040
1040
  private clipperService;
1041
1041
  readonly useSelections: _angular_core.InputSignal<boolean>;
1042
- readonly selectionSource: _angular_core.InputSignal<"bag" | "selection" | "none">;
1042
+ readonly selectionSource: _angular_core.InputSignal<"selection" | "bag" | "none">;
1043
1043
  protected selection: () => ClipperDocumentInfo[];
1044
1044
  readonly parent: _angular_core.InputSignal<ClipperSearchResultManager>;
1045
1045
  readonly item: _angular_core.InputSignal<ClipperDocumentInfo>;
package/core/index.d.ts CHANGED
@@ -564,11 +564,10 @@ declare class DateInterval {
564
564
  }
565
565
  interface LoginResult<T> extends ApiResult<boolean> {
566
566
  context: T;
567
+ oauth?: number;
567
568
  authToken: string;
568
- refreshToken?: string;
569
569
  rememberToken?: string;
570
570
  requiresMfa?: boolean;
571
- mfaToken?: string;
572
571
  }
573
572
 
574
573
  declare class DateIntervalChangeDirective implements OnInit, OnDestroy {
@@ -11,16 +11,23 @@ declare const EvolutionMessages: {
11
11
  LOGIN_CHANGED: string;
12
12
  LOGIN_COMPLETED: string;
13
13
  LOGOUT_COMPLETED: string;
14
+ LOGIN_PENDING: string;
14
15
  LOGOUT: string;
15
16
  };
16
17
 
18
+ declare enum EvolutionLoginFlags {
19
+ None = 0,
20
+ RememberCredentials = 1,
21
+ DisableMfa = 2,
22
+ ExtendMfaValidity = 4,
23
+ ExtendRememberCredentialsValidity = 8
24
+ }
17
25
  interface EvolutionLoginResult extends LoginResult<EvolutionUserInfo> {
18
26
  token?: string;
19
27
  }
20
28
  interface EvolutionLoginInfo {
21
29
  context: EvolutionUserInfo;
22
- userCredentials?: string;
23
- OAUTH?: LoginOAuthType;
30
+ oauth?: LoginOAuthType;
24
31
  }
25
32
  interface EvolutionUserLink {
26
33
  id?: number;
@@ -726,10 +733,9 @@ declare class EvolutionService implements OnDestroy {
726
733
  private _flags;
727
734
  get flags(): EvolutionServiceFlags;
728
735
  private _loginInfo?;
729
- get loginInfo(): EvolutionUserInfo | undefined;
736
+ get loginInfo(): EvolutionLoginInfo | undefined;
730
737
  readonly loggedIn: i0.WritableSignal<boolean>;
731
738
  readonly loggingIn: i0.WritableSignal<boolean>;
732
- readonly shouldRefreshToken: i0.WritableSignal<boolean>;
733
739
  private keepAlive;
734
740
  ngOnDestroy(): void;
735
741
  /**
@@ -742,10 +748,6 @@ declare class EvolutionService implements OnDestroy {
742
748
  * Get access token expiration date
743
749
  */
744
750
  private getTokenExpirationDate;
745
- /**
746
- * Checks if access token in expired
747
- */
748
- isTokenExpired(): boolean;
749
751
  /**
750
752
  * Set keep alive
751
753
  */
@@ -767,11 +769,20 @@ declare class EvolutionService implements OnDestroy {
767
769
  * Return current JWT token
768
770
  * @param refresh: true to get the refresh token. Default is false.
769
771
  */
770
- getToken(refresh?: boolean): string | undefined;
772
+ getAuthToken(): string | undefined;
773
+ /**
774
+ * Get the two form factor authentication token
775
+ */
776
+ getRememberToken(): string | undefined;
771
777
  /**
772
778
  * Store login info
773
779
  */
774
- storeLogin(): void;
780
+ storeContext(): void;
781
+ /**
782
+ * Update context
783
+ * @param result: the new context
784
+ */
785
+ updateContext(result: EvolutionLoginResult): void;
775
786
  /**
776
787
  * Perform auto login using current link data
777
788
  * @param email: the optional email if using OAuth2
@@ -781,7 +792,7 @@ declare class EvolutionService implements OnDestroy {
781
792
  * @param oauthAccessToken: the optional OAuth2 access token
782
793
  * @param onSuccess: function to execute on seccess
783
794
  */
784
- autoLogin(email?: string, password?: string, remember?: boolean, oauth?: LoginOAuthType, oauthAccessToken?: string, onSuccess?: Function): boolean;
795
+ autoLogin(email?: string, password?: string, remember?: boolean, oauth?: LoginOAuthType, oauthAccessToken?: string, onSuccess?: Function, flags?: EvolutionLoginFlags): boolean;
785
796
  /**
786
797
  * Perform auto logout
787
798
  * @param onSuccess: function to execute on seccess
@@ -794,9 +805,21 @@ declare class EvolutionService implements OnDestroy {
794
805
  * @param remember: remember credentials
795
806
  * @param oauth: the optional open authentication supported
796
807
  * @param oauthAccessToken: the optional OAuth2 access token
808
+ * @param flags: the optional login flags
797
809
  * @returns: the login result
798
810
  */
799
- login(email?: string, password?: string, remember?: boolean, oauth?: LoginOAuthType, oauthAccessToken?: string): rxjs.Observable<ApiResult<EvolutionLoginResult>>;
811
+ login(email?: string, password?: string, remember?: boolean, oauth?: LoginOAuthType, oauthAccessToken?: string, flags?: EvolutionLoginFlags): rxjs.Observable<ApiResult<EvolutionLoginResult>>;
812
+ /**
813
+ * Complete login
814
+ * @param result : the login result
815
+ */
816
+ private completeLogin;
817
+ /**
818
+ * Confirm MFA procedure
819
+ * @param code: the confirm code
820
+ * @param flags: the login flags
821
+ */
822
+ confirmIdentity(code: string, flags?: number): rxjs.Observable<ApiResult<EvolutionLoginResult>>;
800
823
  /**
801
824
  * Perform logout
802
825
  */
@@ -806,18 +829,15 @@ declare class EvolutionService implements OnDestroy {
806
829
  * @param id : new user id
807
830
  */
808
831
  loginSwitch(id: number): rxjs.Observable<ApiResult<EvolutionLoginResult>>;
809
- /**
810
- * Handle login error
811
- */
812
- private handleLoginError;
813
832
  /**
814
833
  * Reset login refresh timer and login state
815
834
  */
816
835
  reset(): void;
817
836
  /**
818
837
  * Clear login data
838
+ * @param clearOAuthToken: true to clear oauth token also
819
839
  */
820
- clear(): void;
840
+ clear(clearOAuthToken?: boolean): void;
821
841
  /**
822
842
  * Perform token refresh
823
843
  */
@@ -891,5 +911,5 @@ declare class EvolutionCommonModule {
891
911
  static ɵinj: i0.ɵɵInjectorDeclaration<EvolutionCommonModule>;
892
912
  }
893
913
 
894
- export { ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType, EvolutionAuthInterceptor, EvolutionCommonModule, EvolutionComplianceActivityStates, EvolutionComplianceContextInfo, EvolutionComplianceLawChangeStates, EvolutionComplianceLawOrigins, EvolutionComplianceLawStates, EvolutionComplianceNotificationLimits, EvolutionComplianceNotifications, EvolutionComplianceObligationAuthorities, EvolutionComplianceObligationTypes, EvolutionComplianceProfileFlags, EvolutionComplianceProfileRoles, EvolutionComplianceScopes, EvolutionMessages, EvolutionRecurrenceFrequencyTypes, EvolutionService, EvolutionServiceFlags };
914
+ export { ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType, EvolutionAuthInterceptor, EvolutionCommonModule, EvolutionComplianceActivityStates, EvolutionComplianceContextInfo, EvolutionComplianceLawChangeStates, EvolutionComplianceLawOrigins, EvolutionComplianceLawStates, EvolutionComplianceNotificationLimits, EvolutionComplianceNotifications, EvolutionComplianceObligationAuthorities, EvolutionComplianceObligationTypes, EvolutionComplianceProfileFlags, EvolutionComplianceProfileRoles, EvolutionComplianceScopes, EvolutionLoginFlags, EvolutionMessages, EvolutionRecurrenceFrequencyTypes, EvolutionService, EvolutionServiceFlags };
895
915
  export type { ComplianceRegisterUsersResultModel, EvolutionChangeContextModel, EvolutionChangeContextResultModel, EvolutionComplianceActivitiesAddParams, EvolutionComplianceActivity, EvolutionComplianceLaswExportParams, EvolutionComplianceLaw, EvolutionComplianceLawDocumentInfo, EvolutionComplianceLawReference, EvolutionComplianceLawsAddParams, EvolutionComplianceRegister, EvolutionComplianceRegisterProfile, EvolutionComplianceRegisterSite, EvolutionContextInfo, EvolutionExportModel, EvolutionLicenceModuleInfo, EvolutionLoginInfo, EvolutionLoginResult, EvolutionPermission, EvolutionPlacePermission, EvolutionPlaceable, EvolutionQueryRegisterProfilesModel, EvolutionRegisterProfileSiteInfo, EvolutionRegisterProfileUserInfo, EvolutionUserInfo, EvolutionUserLink, EvolutionUserModuleInfo };
@@ -2011,7 +2011,6 @@ class ClipperService {
2011
2011
  this.loggingIn = signal(false, ...(ngDevMode ? [{ debugName: "loggingIn" }] : []));
2012
2012
  this.snapshot = signal(undefined, ...(ngDevMode ? [{ debugName: "snapshot" }] : []));
2013
2013
  this.supportsRS = signal(false, ...(ngDevMode ? [{ debugName: "supportsRS" }] : []));
2014
- this.shouldRefreshToken = signal(false, ...(ngDevMode ? [{ debugName: "shouldRefreshToken" }] : []));
2015
2014
  this.referencesSnapshot = signal(undefined, ...(ngDevMode ? [{ debugName: "referencesSnapshot" }] : []));
2016
2015
  this.dashboard = new ClipperDashboard();
2017
2016
  this.bag = signal([], ...(ngDevMode ? [{ debugName: "bag" }] : []));
@@ -2128,8 +2127,6 @@ class ClipperService {
2128
2127
  if (!tokenExpired || this.loggedIn()) {
2129
2128
  // Auto login
2130
2129
  this.loggedIn.set(true);
2131
- // Should refresh
2132
- this.shouldRefreshToken.set(!!tokenExpirationDate);
2133
2130
  // Keep alive
2134
2131
  this.setKeepAlive();
2135
2132
  // Initialize channels
@@ -2150,14 +2147,6 @@ class ClipperService {
2150
2147
  // Set a timeout to refresh the token a minute before it expires
2151
2148
  return new Date(jwtToken.exp * 1000);
2152
2149
  }
2153
- /**
2154
- * Checks if access token in expired
2155
- */
2156
- isTokenExpired() {
2157
- const expires = this.getTokenExpirationDate();
2158
- const expired = !expires || expires.getTime() < Date.now();
2159
- return expired;
2160
- }
2161
2150
  /**
2162
2151
  * Set keep alive
2163
2152
  */
@@ -2247,7 +2236,7 @@ class ClipperService {
2247
2236
  if (remember) {
2248
2237
  flags |= ClipperLoginFlags.RememberCredentials;
2249
2238
  }
2250
- this.login(email, password, remember, oauth, oauthAccessToken, flags)
2239
+ this.login(email ?? this.getRememberToken(), password, remember, oauth, oauthAccessToken, flags)
2251
2240
  .subscribe({
2252
2241
  next: r => {
2253
2242
  if (!r.success) {
@@ -2275,6 +2264,7 @@ class ClipperService {
2275
2264
  next: r => {
2276
2265
  if (!r.success) {
2277
2266
  this.dialogService.error(r.message, undefined, "Errore in Clipper");
2267
+ this.broadcastService.sendMessage(ClipperMessages.LOGIN_CHANGED);
2278
2268
  }
2279
2269
  else {
2280
2270
  this.dialogService.toast('Disconnesso da Clipper', 1500, 'power_off');
@@ -2382,7 +2372,7 @@ class ClipperService {
2382
2372
  return this.httpClient.post(this._serviceUri + '/logout', {}).pipe(finalize(() => {
2383
2373
  this.removeKeepAlive();
2384
2374
  this.clear(true);
2385
- // Remove credentials
2375
+ // Clean up
2386
2376
  localStorage.removeItem('clipper_context');
2387
2377
  localStorage.removeItem('clipper_remember');
2388
2378
  }), catchError((_e) => {
@@ -2408,8 +2398,8 @@ class ClipperService {
2408
2398
  */
2409
2399
  clear(clearOAuthToken = false) {
2410
2400
  // Clear local storage
2401
+ localStorage.removeItem('clipper_context');
2411
2402
  sessionStorage.removeItem('clipper_auth');
2412
- sessionStorage.removeItem('clipper_refresh');
2413
2403
  sessionStorage.removeItem('clipper_oauth');
2414
2404
  if (clearOAuthToken) {
2415
2405
  sessionStorage.removeItem('clipper_oauth_token');