@smart-factor/gem-ui-components 0.0.138 → 0.0.139

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.
@@ -1 +1,2 @@
1
- export declare function clearAuthOnTerminate(): void;
1
+ export type TerminationReason = 'logout' | 'expired';
2
+ export declare function clearAuthOnTerminate(reason?: TerminationReason): void;
@@ -5,5 +5,7 @@ export type { NormalizedUser } from './normalizeUser';
5
5
  export { getProjection, normalizeUser } from './normalizeUser';
6
6
  export type { AppDetailsResponse, AppInfo } from './queryAppInfo';
7
7
  export { queryAppInfo, setAppInfoToStorage } from './queryAppInfo';
8
+ export type { NormalizedSession } from './session';
8
9
  export { setAuthCookies } from './setAuthCookies';
9
- export { setAuthSession } from './setAuthSession';
10
+ export { setAuthSessionLegacy as setAuthSession, setAuthSessionLegacy, } from './setAuthSession';
11
+ export { getSession, useSession } from './useSession';
@@ -0,0 +1,32 @@
1
+ import { NormalizedUser } from './normalizeUser';
2
+ export type SessionState = 'UNAUTHORIZED' | 'AUTHORIZED' | 'EXPIRED';
3
+ export type SessionConsent = {
4
+ consent: boolean;
5
+ consent_expiration_date: string | null;
6
+ };
7
+ export type SessionStorageObject = {
8
+ 'x-auth-token': string | null;
9
+ 'x-auth-login': string | null;
10
+ domain: string | null;
11
+ licenses: string[];
12
+ roles: string[];
13
+ consent: SessionConsent | null;
14
+ state: SessionState;
15
+ };
16
+ export type NormalizedSession = SessionStorageObject;
17
+ export declare const SESSION_LOCAL_STORAGE_KEY = "session";
18
+ export declare const SESSION_CHANGED_EVENT = "gem-session-changed";
19
+ export declare function getSession(): SessionStorageObject;
20
+ export declare function updateSession(updater: (current: SessionStorageObject) => SessionStorageObject): SessionStorageObject;
21
+ export declare function applyLoginSession(params: {
22
+ token: string;
23
+ user: NormalizedUser;
24
+ domain: string;
25
+ licenses: string | string[];
26
+ }): SessionStorageObject;
27
+ export declare function updateSessionFromAppInfo(params: {
28
+ domain: string;
29
+ licenses: string | string[];
30
+ }): SessionStorageObject;
31
+ export declare function clearSessionOnLogout(): SessionStorageObject;
32
+ export declare function clearSessionOnExpired(): SessionStorageObject;
@@ -1,2 +1,2 @@
1
1
  import { NormalizedUser } from './normalizeUser';
2
- export declare function setAuthSession(token: string, user: NormalizedUser): void;
2
+ export declare function setAuthSessionLegacy(token: string, user: NormalizedUser): void;
@@ -0,0 +1,3 @@
1
+ import { NormalizedSession } from './session';
2
+ export declare function getSession(): NormalizedSession;
3
+ export declare function useSession(): NormalizedSession;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-factor/gem-ui-components",
3
- "version": "0.0.138",
3
+ "version": "0.0.139",
4
4
  "private": false,
5
5
  "description": "Gem UI Components",
6
6
  "type": "module",