@arsedizioni/ars-utils 22.5.15 → 22.5.16

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.
@@ -201,6 +201,19 @@ interface ClipperUserInfo {
201
201
  interface ClipperLoginResult extends LoginResult<ClipperUserInfo> {
202
202
  settings?: ClipperChannelSettings[];
203
203
  }
204
+ /**
205
+ * Answer of `GET /session/status`: whether this browser holds a live session towards the Clipper API.
206
+ *
207
+ * This is the probe behind the link state. The auth cookie is HttpOnly and belongs to the API's
208
+ * host, so nothing here can read it, and its presence would prove nothing anyway — the session also
209
+ * lives server-side and may have been revoked or evicted. The endpoint never answers 401, which is
210
+ * what makes it safe to call with no session at all: a probe that failed with a status code would be
211
+ * reported by the interceptor as an expired session.
212
+ */
213
+ interface ClipperSessionStatus {
214
+ /** True when the cookie this browser presented resolves to a live, validated session. */
215
+ connected: boolean;
216
+ }
204
217
  interface ClipperLoginInfo {
205
218
  context?: ClipperUserInfo;
206
219
  channels?: ClipperChannelSettings[];
@@ -1010,12 +1023,17 @@ declare class ClipperLoginService {
1010
1023
  */
1011
1024
  get user(): ClipperUserInfo | undefined;
1012
1025
  /**
1013
- * Validates a context that survived a page refresh before trusting it.
1026
+ * Establishes the session state at bootstrap by asking the API — the only party that can read the
1027
+ * HttpOnly cookie — whether this browser still holds one.
1014
1028
  *
1015
1029
  * Called by `ClipperService.initialize`, right after `ClipperCoreService.initialize`, so a
1016
- * consumer gets the restore for free and never has to know this method exists. The auth cookie is
1017
- * HttpOnly and may have expired while the stored context lived on, so a stored context only ever
1018
- * means "there WAS a session" — this is what turns it into "there is one".
1030
+ * consumer gets the restore for free and never has to know this method exists.
1031
+ *
1032
+ * The probe now runs UNCONDITIONALLY, where it used to run only when a stored context existed.
1033
+ * The stored context is just a hint — "this browser signed in at some point" — and the cookie can
1034
+ * outlive it: local storage cleared while the month-long cookie stayed put made this library
1035
+ * declare "no link" with a perfectly valid session in the browser. The API is the only source of
1036
+ * truth on the matter, so it is asked every time.
1019
1037
  *
1020
1038
  * A host application that drives its own return from an external provider, or that starts on its
1021
1039
  * own sign-in page, should call `core.setLoggedIn(false)` before bootstrapping rather than let
@@ -1024,12 +1042,17 @@ declare class ClipperLoginService {
1024
1042
  */
1025
1043
  initialize(): void;
1026
1044
  /**
1027
- * Asks `/session/me` whether the restored session is still alive. On success the login is
1028
- * finalised from the current claims; on a dead session the interceptor's 401 handling takes over.
1045
+ * Asks `/session/status` whether this browser holds a live session, and hydrates the context
1046
+ * through {@link me} when it does.
1047
+ *
1048
+ * The probe is silent by construction: `/session/status` never answers 401, so a visitor who
1049
+ * never signed in — or a cookie whose session has died — comes back as `connected: false` with no
1050
+ * error broadcast and no dialog. Only then is the stale stored context cleared, so the `loggedIn`
1051
+ * signal tells the truth at every bootstrap.
1029
1052
  *
1030
- * Nothing is cleared on failure, and that is deliberate: a failure here is not proof of a dead
1031
- * session — the API may be unreachable, the proxy may have answered 502, the device may be
1032
- * offline. Clearing on any of those would sign the user out with a perfectly valid cookie.
1053
+ * Nothing is cleared on a transport failure, and that is deliberate: an unreachable API is not
1054
+ * proof of a dead session — the proxy may have answered 502, the device may be offline — and
1055
+ * clearing on any of those would sign the user out with a perfectly valid cookie.
1033
1056
  * @returns void
1034
1057
  */
1035
1058
  private restoreSession;
@@ -1062,6 +1085,15 @@ declare class ClipperLoginService {
1062
1085
  * @returns An observable that emits once the logout has been processed.
1063
1086
  */
1064
1087
  logout(): Observable<ApiResult<unknown>>;
1088
+ /**
1089
+ * Asks the API whether this browser holds a live session, without ever failing with a 401: the
1090
+ * route is anonymous and answers `connected: false` to a caller with no session. This is the one
1091
+ * honest way to know the link state — the auth cookie is HttpOnly and belongs to the API's host,
1092
+ * so it cannot be read from here, and its presence would prove nothing anyway, since the session
1093
+ * also lives server-side and may have been revoked or evicted.
1094
+ * @returns An observable emitting the API result wrapping the session status.
1095
+ */
1096
+ status(): Observable<ApiResult<ClipperSessionStatus>>;
1065
1097
  /**
1066
1098
  * Reads the current session from the server, which resolves it from the auth cookie claims
1067
1099
  * without touching the database. Used to restore the state after a page refresh instead of
@@ -1299,4 +1331,4 @@ declare class ClipperCoreService {
1299
1331
  }
1300
1332
 
1301
1333
  export { ClipperAccountService, ClipperAuthors, ClipperCalendarSearchParams, ClipperCalendarState, ClipperCalendarStates, ClipperChannel, ClipperChannelSettings, ClipperChannels, ClipperCoreService, ClipperDashboard, ClipperDocumentChangeReasons, ClipperDocumentContainer, ClipperDocumentsService, ClipperExportDocumentsFormat, ClipperFacet, ClipperLoginService, ClipperMessages, ClipperModel, ClipperModels, ClipperModule, ClipperModuleGroup, ClipperModuleGroups, ClipperModules, ClipperQueryDocumentFlags, ClipperQueryReferencesMode, ClipperRegions, ClipperSearchCalendarSnapshotResult, ClipperSearchFacetsSnapshot, ClipperSearchParams, ClipperSearchResult, ClipperSearchUtils, ClipperSectorTypes, ClipperSectors, ClipperSelectionMode, ClipperService, ClipperServiceFlags, ClipperSort, ClipperSources, ClipperUtils, clipperAuthInterceptor };
1302
- export type { ClipperAvailableChannel, ClipperChannelSettingsItem, ClipperDashboardItem, ClipperDashboardModelItem, ClipperDeleteWorkingDocumentsParams, ClipperDocumentAnchorInfo, ClipperDocumentInfo, ClipperDocumentNote, ClipperDocumentNoteTracking, ClipperDocumentRelevantChunkHit, ClipperDocumentRelevants, ClipperDocumentStructure, ClipperDocumentUpdateStateParams, ClipperExportDocumentsParams, ClipperLoginInfo, ClipperLoginResult, ClipperOTPInfo, ClipperReferencesSearchParams, ClipperSearchCalendarSnapshotMonth, ClipperSearchFacet, ClipperSearchFacetGroup, ClipperSearchFacetsResult, ClipperSearchFilter, ClipperSendDocumentsByEmailParams, ClipperTaxonomyParams, ClipperTopicInfo, ClipperUserChannelInfo, ClipperUserInfo, ClipperUserSearch, ClipperUserTrialInfo, ClipperUserWorkingDocument, EditedEventArgs, SectorInfo };
1334
+ export type { ClipperAvailableChannel, ClipperChannelSettingsItem, ClipperDashboardItem, ClipperDashboardModelItem, ClipperDeleteWorkingDocumentsParams, ClipperDocumentAnchorInfo, ClipperDocumentInfo, ClipperDocumentNote, ClipperDocumentNoteTracking, ClipperDocumentRelevantChunkHit, ClipperDocumentRelevants, ClipperDocumentStructure, ClipperDocumentUpdateStateParams, ClipperExportDocumentsParams, ClipperLoginInfo, ClipperLoginResult, ClipperOTPInfo, ClipperReferencesSearchParams, ClipperSearchCalendarSnapshotMonth, ClipperSearchFacet, ClipperSearchFacetGroup, ClipperSearchFacetsResult, ClipperSearchFilter, ClipperSendDocumentsByEmailParams, ClipperSessionStatus, ClipperTaxonomyParams, ClipperTopicInfo, ClipperUserChannelInfo, ClipperUserInfo, ClipperUserSearch, ClipperUserTrialInfo, ClipperUserWorkingDocument, EditedEventArgs, SectorInfo };
@@ -46,6 +46,20 @@ interface EvolutionLoginResult {
46
46
  */
47
47
  requiresPasswordChange?: boolean;
48
48
  }
49
+ /**
50
+ * Answer of `GET /session/status`: whether this browser holds a live session towards the Evolution
51
+ * API.
52
+ *
53
+ * This is the probe behind the link state. The auth cookie is HttpOnly and belongs to the API's
54
+ * host, so nothing here can read it, and its presence would prove nothing anyway — the session also
55
+ * lives server-side and may have been revoked or evicted. The endpoint never answers 401, which is
56
+ * what makes it safe to call with no session at all: a probe that failed with a status code would be
57
+ * reported by the interceptor as an expired session.
58
+ */
59
+ interface EvolutionSessionStatus {
60
+ /** True when the cookie this browser presented resolves to a live, validated session. */
61
+ connected: boolean;
62
+ }
49
63
  /**
50
64
  * The session as this library holds it, persisted so a page refresh has something to validate.
51
65
  *
@@ -957,8 +971,8 @@ declare class LoginService {
957
971
  */
958
972
  clear(): void;
959
973
  /**
960
- * Initialises the service with the back-end URI and optional feature flags, and revalidates a
961
- * session that survived a page refresh instead of assuming it is still there.
974
+ * Initialises the service with the back-end URI and optional feature flags, and asks the API — the
975
+ * only party that can read the HttpOnly cookie — whether this browser still holds a session.
962
976
  *
963
977
  * Must be called once during application bootstrap, before any other method. What it used to do
964
978
  * on a refresh was announce `LOGIN_COMPLETED` on the strength of a value in local storage; the
@@ -1009,6 +1023,15 @@ declare class LoginService {
1009
1023
  * @returns An observable that emits the `ApiResult<EvolutionLoginResult>`.
1010
1024
  */
1011
1025
  confirmIdentity(code: string, email?: string): Observable<ApiResult<EvolutionLoginResult>>;
1026
+ /**
1027
+ * Asks the API whether this browser holds a live session, without ever failing with a 401: the
1028
+ * route is anonymous and answers `connected: false` to a caller with no session. This is the one
1029
+ * honest way to know the link state -- the auth cookie is HttpOnly and belongs to the API's host,
1030
+ * so it cannot be read from here, and its presence would prove nothing anyway, since the session
1031
+ * also lives server-side and may have been revoked or evicted.
1032
+ * @returns An observable that emits the `ApiResult<EvolutionSessionStatus>`.
1033
+ */
1034
+ status(): Observable<ApiResult<EvolutionSessionStatus>>;
1012
1035
  /**
1013
1036
  * Reads the current session from the server, which resolves it from the auth cookie's claims.
1014
1037
  * Used to restore the state after a page refresh instead of trusting what local storage holds.
@@ -1020,13 +1043,17 @@ declare class LoginService {
1020
1043
  */
1021
1044
  me(): Observable<ApiResult<EvolutionLoginResult>>;
1022
1045
  /**
1023
- * Asks `/session/me` whether the restored session is still alive, and announces the login when it
1024
- * is.
1046
+ * Asks `/session/status` whether this browser holds a live session, and hydrates the context
1047
+ * through {@link me} when it does.
1048
+ *
1049
+ * The probe is silent by construction: `/session/status` never answers 401, so a visitor who
1050
+ * never signed in -- or a cookie whose session has died -- comes back as `connected: false` with
1051
+ * no error broadcast and no dialog. Only then is the stale stored context cleared, so the
1052
+ * `loggedIn` signal tells the truth at every bootstrap.
1025
1053
  *
1026
- * Nothing is cleared on failure, and that is deliberate: a failure here is not proof of a dead
1027
- * session -- the API may be unreachable, the proxy may have answered 502, the device may be
1028
- * offline -- and clearing on any of those would sign the user out with a perfectly valid cookie.
1029
- * A genuine 401 is a different matter and the interceptor has already reported it.
1054
+ * Nothing is cleared on a transport failure, and that is deliberate: an unreachable API is not
1055
+ * proof of a dead session -- the proxy may have answered 502, the device may be offline -- and
1056
+ * clearing on any of those would sign the user out with a perfectly valid cookie.
1030
1057
  * @returns void
1031
1058
  */
1032
1059
  private restoreSession;
@@ -1239,8 +1266,9 @@ declare class EvolutionService {
1239
1266
  get user(): EvolutionUserInfo | undefined;
1240
1267
  /**
1241
1268
  * `true` when this browser has a session the API has accepted. It starts from the stored context
1242
- * and is confirmed -- or left to the interceptor's 401 handling -- by the `/session/me` call
1243
- * {@link initialize} makes.
1269
+ * and is settled -- raised or cleared -- by the silent `/session/status` probe {@link initialize}
1270
+ * makes, which is the one honest way to read a state that lives in an HttpOnly cookie plus a
1271
+ * server-side lease. This signal IS the link state: bind it, do not poll it.
1244
1272
  */
1245
1273
  get loggedIn(): Signal<boolean>;
1246
1274
  /** `true` while an authentication is in flight. */
@@ -1262,4 +1290,4 @@ declare class EvolutionService {
1262
1290
  }
1263
1291
 
1264
1292
  export { AccountService, ComplianceService, ERPComplianceActivityState, ERPComplianceLawOrigin, ERPComplianceLawState, ERPComplianceLawsSelectionType, ERPComplianceNotificationLimit, ERPComplianceProfileFlags, ERPComplianceProfileRole, ERPComplianceRegisterNotificationType, ERPComplianceRegisterSiteImportOptions, ERPComplianceScope, ERPExportFormat, ERPExportPart, ERPExportSource, ERPExportType, ERPModule, ERPPlace, ERPPlacePermission, ERPRecurrenceFrequencyType, EVOLUTION_ACTIVE_ACCOUNT_KEY, EvolutionComplianceActivityStates, EvolutionComplianceContextInfo, EvolutionComplianceLawChangeStates, EvolutionComplianceLawOrigins, EvolutionComplianceLawStates, EvolutionComplianceNotificationLimits, EvolutionComplianceNotifications, EvolutionComplianceObligationAuthorities, EvolutionComplianceObligationTypes, EvolutionComplianceProfileFlags, EvolutionComplianceProfileRoles, EvolutionComplianceScopes, EvolutionMessages, EvolutionRecurrenceFrequencyTypes, EvolutionService, EvolutionServiceFlags, LoginService, evolutionAuthInterceptor };
1265
- export type { ComplianceRegisterUsersResultModel, EvolutionChangeContextModel, EvolutionChangeContextResultModel, EvolutionComplianceActivitiesAddParams, EvolutionComplianceActivity, EvolutionComplianceLaswExportParams, EvolutionComplianceLaw, EvolutionComplianceLawDocumentInfo, EvolutionComplianceLawReference, EvolutionComplianceLawsAddParams, EvolutionComplianceRegister, EvolutionComplianceRegisterProfile, EvolutionComplianceRegisterSite, EvolutionContextInfo, EvolutionExportModel, EvolutionLicenceModuleInfo, EvolutionLoginInfo, EvolutionLoginResult, EvolutionPermission, EvolutionPlacePermission, EvolutionPlaceable, EvolutionQueryRegisterProfilesModel, EvolutionRecoverPasswordModel, EvolutionRegisterProfileSiteInfo, EvolutionRegisterProfileUserInfo, EvolutionResetPasswordModel, EvolutionUpdateUserSettingsModel, EvolutionUserInfo, EvolutionUserLink, EvolutionUserModuleInfo };
1293
+ export type { ComplianceRegisterUsersResultModel, EvolutionChangeContextModel, EvolutionChangeContextResultModel, EvolutionComplianceActivitiesAddParams, EvolutionComplianceActivity, EvolutionComplianceLaswExportParams, EvolutionComplianceLaw, EvolutionComplianceLawDocumentInfo, EvolutionComplianceLawReference, EvolutionComplianceLawsAddParams, EvolutionComplianceRegister, EvolutionComplianceRegisterProfile, EvolutionComplianceRegisterSite, EvolutionContextInfo, EvolutionExportModel, EvolutionLicenceModuleInfo, EvolutionLoginInfo, EvolutionLoginResult, EvolutionPermission, EvolutionPlacePermission, EvolutionPlaceable, EvolutionQueryRegisterProfilesModel, EvolutionRecoverPasswordModel, EvolutionRegisterProfileSiteInfo, EvolutionRegisterProfileUserInfo, EvolutionResetPasswordModel, EvolutionSessionStatus, EvolutionUpdateUserSettingsModel, EvolutionUserInfo, EvolutionUserLink, EvolutionUserModuleInfo };