andoncloud-sdk 1.7.18 → 1.7.19

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.
@@ -12,50 +12,81 @@ interface Credentials {
12
12
  password?: string;
13
13
  signal?: AbortSignal;
14
14
  }
15
- declare class SessionAPI {
16
- baseUrl: string;
17
- clientId: string;
18
- redirectUri: string;
19
- setAuthConfig({ baseUrl, clientId, redirectUri }: AuthConfig): void;
20
- authorize(credentials: Credentials): Promise<Session | null>;
21
- getUserData(authData?: {
22
- token_type: string;
23
- access_token: string;
24
- }): Promise<UserData | null>;
25
- signOut(token: string): Promise<void>;
26
- }
27
- declare class SessionStore {
15
+ declare function createSessionStore(): {
28
16
  loading: boolean;
29
17
  loginStatus: LoginStatus;
30
18
  session: Session | null;
31
- api: SessionAPI;
32
19
  networkError: {
33
20
  title: string;
34
21
  details: string;
35
22
  } | null;
36
23
  refreshTokenPromise: Promise<Session | null> | null;
37
- constructor();
24
+ api: {
25
+ setAuthConfig(config: AuthConfig): void;
26
+ authorize(credentials: Credentials): Promise<Session | null>;
27
+ getUserData(authData?: {
28
+ token_type: string;
29
+ access_token: string;
30
+ }): Promise<UserData | null>;
31
+ signOut(token: string): Promise<void>;
32
+ };
33
+ readonly isLoggedIn: boolean;
34
+ readonly requestHeaders: Record<string, string>;
38
35
  setLoading(value: boolean): void;
36
+ setAuthConfig(config: AuthConfig): void;
39
37
  setConnectedLoginStatus(): void;
40
38
  setNotAuthorizedLoginStatus(): void;
41
- setAuthConfig(config: AuthConfig): void;
42
39
  setNetworkError(value: {
43
40
  title: string;
44
41
  details: string;
45
42
  } | null): void;
46
- isLoggedIn(): boolean;
47
- requestHeaders(): Record<string, string>;
43
+ storeSession(): void;
44
+ removeSession(): void;
45
+ setCurrentUser(user: UserData | null): void;
46
+ removeCurrentUser(): void;
48
47
  authorize(credentials: Credentials, storeSession?: boolean): Promise<Session | null>;
49
48
  refresh(): Promise<Session | null>;
50
49
  recover(): Promise<void>;
51
- private recoverSession;
52
50
  logout(): Promise<void>;
53
51
  refreshUserData(): Promise<UserData | null>;
52
+ };
53
+ type SessionStore = ReturnType<typeof createSessionStore>;
54
+ declare const sessionStore: {
55
+ loading: boolean;
56
+ loginStatus: LoginStatus;
57
+ session: Session | null;
58
+ networkError: {
59
+ title: string;
60
+ details: string;
61
+ } | null;
62
+ refreshTokenPromise: Promise<Session | null> | null;
63
+ api: {
64
+ setAuthConfig(config: AuthConfig): void;
65
+ authorize(credentials: Credentials): Promise<Session | null>;
66
+ getUserData(authData?: {
67
+ token_type: string;
68
+ access_token: string;
69
+ }): Promise<UserData | null>;
70
+ signOut(token: string): Promise<void>;
71
+ };
72
+ readonly isLoggedIn: boolean;
73
+ readonly requestHeaders: Record<string, string>;
74
+ setLoading(value: boolean): void;
75
+ setAuthConfig(config: AuthConfig): void;
76
+ setConnectedLoginStatus(): void;
77
+ setNotAuthorizedLoginStatus(): void;
78
+ setNetworkError(value: {
79
+ title: string;
80
+ details: string;
81
+ } | null): void;
54
82
  storeSession(): void;
55
- restoreSession(): Promise<void>;
56
83
  removeSession(): void;
57
84
  setCurrentUser(user: UserData | null): void;
58
85
  removeCurrentUser(): void;
59
- }
60
- declare const sessionStore: SessionStore;
61
- export default sessionStore;
86
+ authorize(credentials: Credentials, storeSession?: boolean): Promise<Session | null>;
87
+ refresh(): Promise<Session | null>;
88
+ recover(): Promise<void>;
89
+ logout(): Promise<void>;
90
+ refreshUserData(): Promise<UserData | null>;
91
+ };
92
+ export { sessionStore, type SessionStore };
@@ -1,3 +1,3 @@
1
- export { default } from './SessionStore';
1
+ export { sessionStore, type SessionStore } from './SessionStore';
2
2
  export { TokenCoordinator, tokenCoordinator } from './TokenCoordinator';
3
3
  export type { AuthEvent, AuthEventType, CookieData, LoginFormValidation, LoginStatus, QueuedRequest, Session, UserData, } from './types';
@@ -48,6 +48,38 @@ export interface CookieData {
48
48
  'created-at': number;
49
49
  'expires-in': number;
50
50
  }
51
+ export interface OAuthTokenResponse {
52
+ access_token: string;
53
+ refresh_token: string;
54
+ token_type: string;
55
+ created_at: number;
56
+ expires_in: number;
57
+ error_description?: string;
58
+ }
59
+ export interface MeResponse {
60
+ user: {
61
+ id: number;
62
+ company_id: number;
63
+ role_id: number;
64
+ username: string;
65
+ email: string;
66
+ name: string;
67
+ permissions_map: Record<string, string> | null;
68
+ features_map: Record<string, RawFeatureInfo> | null;
69
+ features_requests_map: Record<string, Record<string, Record<string, RawRequestInfo>>> | null;
70
+ };
71
+ }
72
+ export interface RawFeatureInfo {
73
+ status: string;
74
+ entitlement_type: string;
75
+ expires_at: string | null;
76
+ days_since_expiry: number | null;
77
+ permissions: string[];
78
+ }
79
+ export interface RawRequestInfo {
80
+ last_requested_at: string;
81
+ days_remaining: number;
82
+ }
51
83
  export interface LoginFormValidation {
52
84
  usernameError: string | null;
53
85
  passwordError: string | null;
@@ -1,15 +1,4 @@
1
- import { FeatureInfo } from '../stores/SessionStore/types';
2
- interface RawFeatureInfo {
3
- status: string;
4
- entitlement_type: string;
5
- expires_at: string | null;
6
- days_since_expiry: number | null;
7
- permissions: string[];
8
- }
9
- interface RawRequestInfo {
10
- last_requested_at: string;
11
- days_remaining: number;
12
- }
1
+ import { FeatureInfo, RawFeatureInfo, RawRequestInfo } from '../stores/SessionStore/types';
13
2
  interface CooldownStatus {
14
3
  isInCooldown: boolean;
15
4
  daysRemaining: number;
@@ -1 +1 @@
1
- export declare const LIBRARY_VERSION = "1.7.18";
1
+ export declare const LIBRARY_VERSION = "1.7.19";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "andoncloud-sdk",
3
- "version": "1.7.18",
3
+ "version": "1.7.19",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "source": "src/index.js",