@frontegg/rest-api 3.1.74 → 3.1.76-alpha.9502349697

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.
Files changed (123) hide show
  1. package/BaseApiClient.d.ts +16 -0
  2. package/BaseApiClient.js +39 -0
  3. package/ContextHolder/index.d.ts +108 -27
  4. package/ContextHolder/index.js +155 -50
  5. package/FetchClient.d.ts +42 -0
  6. package/FetchClient.js +308 -0
  7. package/account-settings/index.d.ts +19 -7
  8. package/account-settings/index.js +23 -13
  9. package/applications/index.d.ts +49 -44
  10. package/applications/index.js +51 -37
  11. package/audits/index.d.ts +27 -15
  12. package/audits/index.js +27 -17
  13. package/auth/index.d.ts +817 -768
  14. package/auth/index.js +902 -721
  15. package/auth/secutiry-poilicy/index.d.ts +58 -102
  16. package/auth/secutiry-poilicy/index.js +122 -90
  17. package/auth/utils.d.ts +2 -2
  18. package/auth/utils.js +9 -8
  19. package/connectivity/index.d.ts +126 -27
  20. package/connectivity/index.js +147 -114
  21. package/directory/index.d.ts +31 -22
  22. package/directory/index.js +27 -15
  23. package/entitlements/index.d.ts +14 -8
  24. package/entitlements/index.js +12 -4
  25. package/feature-flags/index.d.ts +8 -2
  26. package/feature-flags/index.js +16 -8
  27. package/groups/index.d.ts +73 -49
  28. package/groups/index.js +64 -45
  29. package/impersonate/index.d.ts +15 -6
  30. package/impersonate/index.js +13 -5
  31. package/index.d.ts +154 -108
  32. package/index.js +109 -78
  33. package/interfaces.d.ts +10 -0
  34. package/metadata/index.d.ts +67 -7
  35. package/metadata/index.js +52 -32
  36. package/node/BaseApiClient.js +49 -0
  37. package/node/ContextHolder/index.js +155 -50
  38. package/node/FetchClient.js +326 -0
  39. package/node/account-settings/index.js +27 -16
  40. package/node/applications/index.js +51 -44
  41. package/node/audits/index.js +31 -20
  42. package/node/auth/index.js +768 -1035
  43. package/node/auth/secutiry-poilicy/index.js +125 -136
  44. package/node/auth/utils.js +9 -7
  45. package/node/connectivity/index.js +148 -187
  46. package/node/directory/index.js +29 -20
  47. package/node/entitlements/index.js +18 -5
  48. package/node/feature-flags/index.js +21 -9
  49. package/node/groups/index.js +65 -63
  50. package/node/impersonate/index.js +18 -5
  51. package/node/index.js +116 -71
  52. package/node/metadata/index.js +61 -52
  53. package/node/notifications/index.js +37 -27
  54. package/node/reports/index.js +78 -70
  55. package/node/roles/index.js +56 -51
  56. package/node/security-center/index.js +21 -9
  57. package/node/sub-tenants/index.js +90 -89
  58. package/node/subscriptions/index.js +69 -107
  59. package/node/subscriptions/invoices.js +25 -17
  60. package/node/subscriptions/managedSubscriptions.js +32 -27
  61. package/node/subscriptions/paymentMethods.js +27 -20
  62. package/node/subscriptions/paymentProviders.js +15 -6
  63. package/node/subscriptions/plans.js +17 -9
  64. package/node/subscriptions/providers/stripe/index.js +26 -21
  65. package/node/subscriptions/subscriptions.js +32 -27
  66. package/node/subscriptions/summaries.js +15 -6
  67. package/node/subscriptions/tenantConfiguration.js +17 -9
  68. package/node/subscriptions/vendorPublicConfigurations.js +15 -6
  69. package/node/teams/index.js +130 -138
  70. package/node/tenants/index.js +65 -60
  71. package/node/user-phone-numbers/index.js +32 -24
  72. package/node/users/index.js +58 -53
  73. package/node/vendor/index.js +17 -6
  74. package/notifications/index.d.ts +22 -16
  75. package/notifications/index.js +33 -22
  76. package/package.json +1 -1
  77. package/reports/index.d.ts +50 -44
  78. package/reports/index.js +75 -62
  79. package/roles/index.d.ts +44 -38
  80. package/roles/index.js +57 -41
  81. package/security-center/index.d.ts +14 -2
  82. package/security-center/index.js +15 -6
  83. package/sub-tenants/index.d.ts +57 -15
  84. package/sub-tenants/index.js +88 -68
  85. package/subscriptions/index.d.ts +56 -11
  86. package/subscriptions/index.js +58 -11
  87. package/subscriptions/invoices.d.ts +16 -13
  88. package/subscriptions/invoices.js +24 -14
  89. package/subscriptions/managedSubscriptions.d.ts +18 -15
  90. package/subscriptions/managedSubscriptions.js +33 -22
  91. package/subscriptions/paymentMethods.d.ts +16 -13
  92. package/subscriptions/paymentMethods.js +26 -17
  93. package/subscriptions/paymentProviders.d.ts +8 -5
  94. package/subscriptions/paymentProviders.js +11 -4
  95. package/subscriptions/plans.d.ts +11 -8
  96. package/subscriptions/plans.js +14 -6
  97. package/subscriptions/providers/stripe/index.d.ts +24 -21
  98. package/subscriptions/providers/stripe/index.js +27 -16
  99. package/subscriptions/subscriptions.d.ts +24 -21
  100. package/subscriptions/subscriptions.js +33 -22
  101. package/subscriptions/summaries.d.ts +7 -4
  102. package/subscriptions/summaries.js +10 -3
  103. package/subscriptions/tenantConfiguration.d.ts +6 -3
  104. package/subscriptions/tenantConfiguration.js +15 -7
  105. package/subscriptions/vendorPublicConfigurations.d.ts +5 -2
  106. package/subscriptions/vendorPublicConfigurations.js +11 -4
  107. package/teams/index.d.ts +35 -131
  108. package/teams/index.js +122 -93
  109. package/tenants/index.d.ts +25 -37
  110. package/tenants/index.js +62 -46
  111. package/tenants/interfaces.d.ts +2 -0
  112. package/user-phone-numbers/index.d.ts +32 -26
  113. package/user-phone-numbers/index.js +32 -19
  114. package/users/index.d.ts +21 -15
  115. package/users/index.js +60 -44
  116. package/vendor/index.d.ts +12 -6
  117. package/vendor/index.js +11 -4
  118. package/fetch.d.ts +0 -24
  119. package/fetch.js +0 -265
  120. package/node/fetch.js +0 -306
  121. package/node/subscriptions/providers/index.js +0 -18
  122. package/subscriptions/providers/index.d.ts +0 -1
  123. package/subscriptions/providers/index.js +0 -1
@@ -0,0 +1,16 @@
1
+ import { FetchClient } from './FetchClient';
2
+ import { RequestOptions, UserJwtOptions } from './interfaces';
3
+ export declare class BaseApiClient {
4
+ protected appName: string;
5
+ protected fetchClient: FetchClient;
6
+ protected constructor(appName: string);
7
+ protected get: <T>(url: string, params?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<T>;
8
+ protected post: <T>(url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<T>;
9
+ protected patch: <T>(url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<T>;
10
+ protected put: <T>(url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<T>;
11
+ protected delete: <T>(url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<T>;
12
+ protected postDownload: <T>(url: string, body?: any, params?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<T>;
13
+ protected extractHeadersFromOptions: (options?: UserJwtOptions) => {
14
+ Authorization?: string;
15
+ };
16
+ }
@@ -0,0 +1,39 @@
1
+ import { FetchClient } from './FetchClient';
2
+ export class BaseApiClient {
3
+ constructor(appName) {
4
+ this.appName = void 0;
5
+ this.fetchClient = void 0;
6
+
7
+ this.get = async (url, params, opts) => {
8
+ return this.fetchClient.get(url, params, opts);
9
+ };
10
+
11
+ this.post = async (url, body, opts) => {
12
+ return this.fetchClient.post(url, body, opts);
13
+ };
14
+
15
+ this.patch = async (url, body, opts) => {
16
+ return this.fetchClient.patch(url, body, opts);
17
+ };
18
+
19
+ this.put = async (url, body, opts) => {
20
+ return this.fetchClient.put(url, body, opts);
21
+ };
22
+
23
+ this.delete = async (url, body, opts) => {
24
+ return this.fetchClient.delete(url, body, opts);
25
+ };
26
+
27
+ this.postDownload = async (url, body, params, opts) => {
28
+ return this.fetchClient.postDownload(url, body, params, opts);
29
+ };
30
+
31
+ this.extractHeadersFromOptions = (options = {}) => {
32
+ return this.fetchClient.extractHeadersFromOptions(options);
33
+ };
34
+
35
+ this.appName = appName;
36
+ this.fetchClient = new FetchClient(appName);
37
+ }
38
+
39
+ }
@@ -1,5 +1,5 @@
1
1
  import { SessionContext, ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
2
- import { IUserProfile } from "../users/interfaces";
2
+ import { IUserProfile } from '../users/interfaces';
3
3
  /**
4
4
  * Entitlements config from frontegg provider
5
5
  */
@@ -7,60 +7,141 @@ export interface EntitlementsOptions {
7
7
  enabled?: boolean;
8
8
  }
9
9
  export declare class ContextHolder {
10
- private static instance;
10
+ private static _apps;
11
11
  private context;
12
12
  private accessToken;
13
13
  private user;
14
14
  private requestSource;
15
- private onRedirectTo;
16
- private logout;
15
+ onRedirectTo: (path: string, opts?: RedirectOptions) => void;
16
+ logout: (callback?: () => void) => void;
17
17
  private entitlementsOptions;
18
18
  private appName;
19
19
  private sessionContext?;
20
20
  private constructor();
21
- static getInstance(): ContextHolder;
22
- static setContext(context: ContextOptions): void;
23
- static setAccessToken(accessToken: string | null): void;
24
- static setUser(user: IUserProfile | null): void;
25
- static setRequestSource(requestSource: RequestSource | null): void;
26
- static setOnRedirectTo(onRedirectTo: (path: string, opts?: RedirectOptions) => void): void;
27
- static setLogout(logout: (callback?: () => void) => void, logoutUrl: string): void;
21
+ static default(): ContextHolder;
22
+ static for(appName: string): ContextHolder;
23
+ /**
24
+ * @deprecated - use ContextHolder.for(appName) / ContextHolder.default() instead
25
+ * @param appName
26
+ */
27
+ static getInstance(appName?: string): ContextHolder;
28
+ static createInstance(appName?: string): ContextHolder;
29
+ /**
30
+ * @deprecated - use ContextHolder.for(appName).setContext instead
31
+ */
32
+ static setContext(context: ContextOptions, appName?: string): void;
33
+ setContext: (context: ContextOptions) => void;
34
+ /**
35
+ * @deprecated - use ContextHolder.for(appName).setAccessToken instead
36
+ */
37
+ static setAccessToken(accessToken: string | null, appName?: string): void;
38
+ setAccessToken: (accessToken: string | null) => void;
39
+ /**
40
+ * @deprecated - use ContextHolder.for(appName).setUser instead
41
+ */
42
+ static setUser(user: IUserProfile | null, appName?: string): void;
43
+ setUser: (user: IUserProfile | null) => void;
44
+ /**
45
+ * @deprecated - use ContextHolder.for(appName).setRequestSource instead
46
+ */
47
+ static setRequestSource(requestSource: RequestSource | null, appName?: string): void;
48
+ setRequestSource: (requestSource: RequestSource | null) => void;
49
+ /**
50
+ * @deprecated - use ContextHolder.for(appName).setOnRedirectTo instead
51
+ */
52
+ static setOnRedirectTo(onRedirectTo: (path: string, opts?: RedirectOptions) => void, appName?: string): void;
53
+ setOnRedirectTo: (onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void) => void;
54
+ /**
55
+ * @deprecated - use ContextHolder.for(appName).setLogout instead
56
+ */
57
+ static setLogout(logout: (callback?: () => void) => void, logoutUrl: string, appName?: string): void;
58
+ setLogout: (logout: (callback?: (() => void) | undefined) => void) => void;
28
59
  /**
29
60
  * App name should also be set for entitlements
61
+ * @deprecated - use ContextHolder.for(appName).setEntitlementsOptions instead
30
62
  * @param entitlementsOptions frontegg options entitlements config
63
+ * @param appName - app name
31
64
  */
32
- static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions): void;
65
+ static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions, appName?: string): void;
66
+ setEntitlementsOptions: (entitlementsOptions: EntitlementsOptions) => void;
33
67
  /**
68
+ * @deprecated - use ContextHolder.for(appName).setSessionContext instead
34
69
  * @param sessionContext frontegg options SessionContext config
70
+ * @param appName - app name
71
+ */
72
+ static setSessionContext(sessionContext: SessionContext, appName?: string): void;
73
+ setSessionContext: (sessionContext: SessionContext) => void;
74
+ /**
75
+ * @deprecated - use ContextHolder.for(appName).setAppName instead
35
76
  */
36
- static setSessionContext(sessionContext: SessionContext): void;
77
+ static setAppName(appName: string): void;
78
+ setAppName: (appName: string) => void;
37
79
  /**
38
- * @param appName for feature flags e.g.
80
+ * @deprecated - use ContextHolder.for(appName).getContext instead
39
81
  */
40
- static setAppName(appName: string | null): void;
41
- static getContext(): ContextOptions;
42
- static getAccessToken(): string | null;
43
- static getRequestSource(): RequestSource | null;
44
- static getUser(): IUserProfile | null;
45
- static onRedirectTo(path: string, opts?: RedirectOptions): void;
46
- static logout(callback?: () => void): void;
82
+ static getContext(appName?: string): ContextOptions;
83
+ getContext: () => ContextOptions;
84
+ /**
85
+ * @deprecated - use ContextHolder.for(appName).getAccessToken instead
86
+ */
87
+ static getAccessToken(appName?: string): string | null;
88
+ getAccessToken: () => string | null;
89
+ /**
90
+ * @deprecated - use ContextHolder.for(appName).requestSource instead
91
+ */
92
+ static getRequestSource(appName?: string): RequestSource | null;
93
+ getRequestSource: () => RequestSource | null;
94
+ /**
95
+ * @deprecated - use ContextHolder.for(appName).getUser instead
96
+ */
97
+ static getUser(appName?: string): IUserProfile | null;
98
+ getUser: () => IUserProfile | null;
99
+ /**
100
+ * @deprecated - use ContextHolder.for(appName).onRedirectTo instead
101
+ */
102
+ static onRedirectTo(path: string, opts?: RedirectOptions, appName?: string): void;
103
+ /**
104
+ * @deprecated - use ContextHolder.for(appName).logout instead
105
+ */
106
+ static logout(callback?: () => void, appName?: string): void;
47
107
  /**
108
+ * @deprecated - use ContextHolder.for(appName).shouldLoadEntitlements instead
48
109
  * @returns shouldLoadEntitlements. Default to false.
49
110
  */
50
- static shouldLoadEntitlements(): boolean;
111
+ static shouldLoadEntitlements(appName?: string): boolean;
112
+ shouldLoadEntitlements: () => boolean;
51
113
  /**
52
- * @returns isSessionPerTenantEnabled. Default to false.
53
- */
54
- static isSessionPerTenantEnabled(): boolean;
114
+ * @deprecated - use ContextHolder.for(appName).isSessionPerTenantEnabled instead
115
+ * @returns isSessionPerTenantEnabled. Default to false.
116
+ */
117
+ static isSessionPerTenantEnabled(appName?: string): boolean;
118
+ isSessionPerTenantEnabled: () => boolean;
55
119
  /**
120
+ * @deprecated - use ContextHolder.for(appName).getAppName instead
56
121
  * @returns app name value
57
122
  */
58
- static getAppName(): string | null;
123
+ static getAppName(appName?: string): string | null;
124
+ getAppName: () => string | null;
59
125
  }
126
+ /**
127
+ * Frontegg context to be used in the application
128
+ *
129
+ * @deprecated use ContextHolder.for instead
130
+ */
60
131
  export declare const FronteggContext: {
61
132
  getContext: () => ContextOptions;
62
133
  getAccessToken: () => string | null;
134
+ setAccessToken: (accessToken: string | null) => void;
63
135
  getUser: () => IUserProfile | null;
64
- onRedirectTo: (path: string, opts: RedirectOptions) => void;
136
+ setUser: (user: IUserProfile | null) => void;
137
+ onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void;
138
+ setOnRedirectTo: (onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void) => void;
65
139
  logout: (callback?: (() => void) | undefined) => void;
140
+ getRequestSource: () => RequestSource | null;
141
+ setRequestSource: (requestSource: RequestSource | null) => void;
142
+ isSessionPerTenantEnabled: () => boolean;
143
+ shouldLoadEntitlements: () => boolean;
144
+ getAppName: () => string | null;
145
+ setEntitlementsOptions: (entitlementsOptions: EntitlementsOptions) => void;
146
+ setSessionContext: (sessionContext: SessionContext) => void;
66
147
  };
@@ -12,111 +12,216 @@ export class ContextHolder {
12
12
  this.entitlementsOptions = null;
13
13
  this.appName = null;
14
14
  this.sessionContext = void 0;
15
+
16
+ this.setContext = context => {
17
+ this.context = context;
18
+ };
19
+
20
+ this.setAccessToken = accessToken => {
21
+ this.accessToken = accessToken;
22
+ };
23
+
24
+ this.setUser = user => {
25
+ this.user = user;
26
+ };
27
+
28
+ this.setRequestSource = requestSource => {
29
+ this.requestSource = requestSource;
30
+ };
31
+
32
+ this.setOnRedirectTo = onRedirectTo => {
33
+ this.onRedirectTo = onRedirectTo;
34
+ };
35
+
36
+ this.setLogout = logout => {
37
+ this.logout = logout;
38
+ };
39
+
40
+ this.setEntitlementsOptions = entitlementsOptions => {
41
+ this.entitlementsOptions = entitlementsOptions;
42
+ };
43
+
44
+ this.setSessionContext = sessionContext => {
45
+ this.sessionContext = sessionContext;
46
+ };
47
+
48
+ this.setAppName = appName => {
49
+ this.appName = appName;
50
+ };
51
+
52
+ this.getContext = () => {
53
+ var _this$context;
54
+
55
+ return (_this$context = this.context) != null ? _this$context : {
56
+ baseUrl: window.location.href,
57
+ tokenResolver: () => 'my-authentication-token',
58
+ logLevel: 'error'
59
+ };
60
+ };
61
+
62
+ this.getAccessToken = () => {
63
+ return this.accessToken;
64
+ };
65
+
66
+ this.getRequestSource = () => {
67
+ return this.requestSource;
68
+ };
69
+
70
+ this.getUser = () => {
71
+ return this.user;
72
+ };
73
+
74
+ this.shouldLoadEntitlements = () => {
75
+ var _this$entitlementsOpt;
76
+
77
+ return ((_this$entitlementsOpt = this.entitlementsOptions) == null ? void 0 : _this$entitlementsOpt.enabled) || false;
78
+ };
79
+
80
+ this.isSessionPerTenantEnabled = () => {
81
+ var _this$sessionContext;
82
+
83
+ return ((_this$sessionContext = this.sessionContext) == null ? void 0 : _this$sessionContext.enableSessionPerTenant) || false;
84
+ };
85
+
86
+ this.getAppName = () => {
87
+ return this.appName;
88
+ };
89
+ }
90
+
91
+ static default() {
92
+ return ContextHolder.getInstance(DEFAULT_APP_NAME);
93
+ }
94
+
95
+ static for(appName) {
96
+ return ContextHolder.getInstance(appName);
15
97
  }
16
98
 
17
- static getInstance() {
18
- if (!ContextHolder.instance) {
19
- ContextHolder.instance = new ContextHolder();
99
+ static getInstance(appName = 'default') {
100
+ if (!ContextHolder._apps) {
101
+ ContextHolder._apps = {};
20
102
  }
21
103
 
22
- return ContextHolder.instance;
104
+ if (ContextHolder._apps[appName]) {
105
+ return ContextHolder._apps[appName];
106
+ }
107
+
108
+ ContextHolder._apps[appName] = new ContextHolder();
109
+ return ContextHolder._apps[appName];
23
110
  }
24
111
 
25
- static setContext(context) {
26
- ContextHolder.getInstance().context = context;
112
+ static createInstance(appName = 'default') {
113
+ ContextHolder._apps[appName] = new ContextHolder();
114
+ ContextHolder._apps[appName].appName = appName;
115
+ return ContextHolder._apps[appName];
27
116
  }
28
117
 
29
- static setAccessToken(accessToken) {
30
- ContextHolder.getInstance().accessToken = accessToken;
118
+ static setContext(context, appName = 'default') {
119
+ ContextHolder.for(appName).context = context;
31
120
  }
32
121
 
33
- static setUser(user) {
34
- ContextHolder.getInstance().user = user;
122
+ static setAccessToken(accessToken, appName = 'default') {
123
+ ContextHolder.for(appName).accessToken = accessToken;
35
124
  }
36
125
 
37
- static setRequestSource(requestSource) {
38
- ContextHolder.getInstance().requestSource = requestSource;
126
+ static setUser(user, appName = 'default') {
127
+ ContextHolder.for(appName).user = user;
39
128
  }
40
129
 
41
- static setOnRedirectTo(onRedirectTo) {
42
- ContextHolder.getInstance().onRedirectTo = onRedirectTo;
130
+ static setRequestSource(requestSource, appName = 'default') {
131
+ ContextHolder.for(appName).requestSource = requestSource;
43
132
  }
44
133
 
45
- static setLogout(logout, logoutUrl) {
46
- ContextHolder.getInstance().logout = callback => {
134
+ static setOnRedirectTo(onRedirectTo, appName = 'default') {
135
+ ContextHolder.for(appName).onRedirectTo = onRedirectTo;
136
+ }
137
+
138
+ static setLogout(logout, logoutUrl, appName = 'default') {
139
+ const context = ContextHolder.for(appName);
140
+
141
+ context.logout = callback => {
47
142
  if (!callback) {
48
- ContextHolder.onRedirectTo(logoutUrl);
143
+ context.onRedirectTo(logoutUrl, undefined);
49
144
  } else {
50
145
  logout(callback);
51
146
  }
52
147
  };
53
148
  }
54
149
 
55
- static setEntitlementsOptions(entitlementsOptions) {
56
- ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
150
+ static setEntitlementsOptions(entitlementsOptions, appName = 'default') {
151
+ ContextHolder.for(appName).entitlementsOptions = entitlementsOptions;
57
152
  }
58
153
 
59
- static setSessionContext(sessionContext) {
60
- const instance = ContextHolder.getInstance();
61
- instance.sessionContext = sessionContext;
154
+ static setSessionContext(sessionContext, appName = 'default') {
155
+ ContextHolder.for(appName).sessionContext = sessionContext;
62
156
  }
63
157
 
64
158
  static setAppName(appName) {
65
- ContextHolder.getInstance().appName = appName;
159
+ ContextHolder.for(appName).appName = appName;
66
160
  }
67
161
 
68
- static getContext() {
69
- var _ContextHolder$getIns;
162
+ static getContext(appName = 'default') {
163
+ var _ContextHolder$for$co;
70
164
 
71
- return (_ContextHolder$getIns = ContextHolder.getInstance().context) != null ? _ContextHolder$getIns : {
165
+ return (_ContextHolder$for$co = ContextHolder.for(appName).context) != null ? _ContextHolder$for$co : {
72
166
  baseUrl: window.location.href,
73
167
  tokenResolver: () => 'my-authentication-token',
74
168
  logLevel: 'error'
75
169
  };
76
170
  }
77
171
 
78
- static getAccessToken() {
79
- return ContextHolder.getInstance().accessToken;
172
+ static getAccessToken(appName = 'default') {
173
+ return ContextHolder.for(appName).accessToken;
80
174
  }
81
175
 
82
- static getRequestSource() {
83
- return ContextHolder.getInstance().requestSource;
176
+ static getRequestSource(appName = 'default') {
177
+ return ContextHolder.for(appName).requestSource;
84
178
  }
85
179
 
86
- static getUser() {
87
- return ContextHolder.getInstance().user;
180
+ static getUser(appName = 'default') {
181
+ return ContextHolder.for(appName).user;
88
182
  }
89
183
 
90
- static onRedirectTo(path, opts) {
91
- return ContextHolder.getInstance().onRedirectTo(path, opts);
184
+ static onRedirectTo(path, opts, appName = 'default') {
185
+ return ContextHolder.for(appName).onRedirectTo(path, opts);
92
186
  }
93
187
 
94
- static logout(callback) {
95
- return ContextHolder.getInstance().logout(callback);
188
+ static logout(callback, appName = 'default') {
189
+ return ContextHolder.for(appName).logout(callback);
96
190
  }
97
191
 
98
- static shouldLoadEntitlements() {
99
- var _ContextHolder$getIns2;
192
+ static shouldLoadEntitlements(appName = 'default') {
193
+ var _ContextHolder$for$en;
100
194
 
101
- return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
195
+ return ((_ContextHolder$for$en = ContextHolder.for(appName).entitlementsOptions) == null ? void 0 : _ContextHolder$for$en.enabled) || false;
102
196
  }
103
197
 
104
- static isSessionPerTenantEnabled() {
105
- var _ContextHolder$getIns3;
198
+ static isSessionPerTenantEnabled(appName = 'default') {
199
+ var _ContextHolder$for$se;
106
200
 
107
- return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
201
+ return ((_ContextHolder$for$se = ContextHolder.for(appName).sessionContext) == null ? void 0 : _ContextHolder$for$se.enableSessionPerTenant) || false;
108
202
  }
109
203
 
110
- static getAppName() {
111
- return ContextHolder.getInstance().appName;
204
+ static getAppName(appName = 'default') {
205
+ return ContextHolder.for(appName).appName;
112
206
  }
113
207
 
114
208
  }
115
- ContextHolder.instance = void 0;
209
+ ContextHolder._apps = void 0;
210
+ const DEFAULT_APP_NAME = 'default';
116
211
  export const FronteggContext = {
117
- getContext: () => ContextHolder.getContext(),
118
- getAccessToken: () => ContextHolder.getAccessToken(),
119
- getUser: () => ContextHolder.getUser(),
120
- onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts),
121
- logout: callback => ContextHolder.logout(callback)
212
+ getContext: () => ContextHolder.getContext(DEFAULT_APP_NAME),
213
+ getAccessToken: () => ContextHolder.getAccessToken(DEFAULT_APP_NAME),
214
+ setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, DEFAULT_APP_NAME),
215
+ getUser: () => ContextHolder.getUser(DEFAULT_APP_NAME),
216
+ setUser: user => ContextHolder.setUser(user, DEFAULT_APP_NAME),
217
+ onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts, DEFAULT_APP_NAME),
218
+ setOnRedirectTo: onRedirectTo => ContextHolder.setOnRedirectTo(onRedirectTo, DEFAULT_APP_NAME),
219
+ logout: callback => ContextHolder.logout(callback, DEFAULT_APP_NAME),
220
+ getRequestSource: () => ContextHolder.getRequestSource(DEFAULT_APP_NAME),
221
+ setRequestSource: requestSource => ContextHolder.setRequestSource(requestSource, DEFAULT_APP_NAME),
222
+ isSessionPerTenantEnabled: () => ContextHolder.isSessionPerTenantEnabled(DEFAULT_APP_NAME),
223
+ shouldLoadEntitlements: () => ContextHolder.shouldLoadEntitlements(DEFAULT_APP_NAME),
224
+ getAppName: () => ContextHolder.getAppName(DEFAULT_APP_NAME),
225
+ setEntitlementsOptions: entitlementsOptions => ContextHolder.setEntitlementsOptions(entitlementsOptions, DEFAULT_APP_NAME),
226
+ setSessionContext: sessionContext => ContextHolder.setSessionContext(sessionContext, DEFAULT_APP_NAME)
122
227
  };
@@ -0,0 +1,42 @@
1
+ import { ContextOptions, RequestOptions, UserJwtOptions } from './interfaces';
2
+ /**
3
+ * FetchClient is a class that wrap around the fetch API to make requests.
4
+ * It is used by the BaseApiClient to make requests to the server
5
+ */
6
+ export declare class FetchClient {
7
+ private appName;
8
+ constructor(appName: string);
9
+ private getFronteggContext;
10
+ private prepareUrl;
11
+ private buildQueryParams;
12
+ private getAdditionalQueryParams;
13
+ private getAdditionalHeaders;
14
+ private buildRequestHeaders;
15
+ sendRequest: (opts: RequestOptions) => Promise<any>;
16
+ get: (url: string, params?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<any>;
17
+ post: (url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<any>;
18
+ patch: (url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<any>;
19
+ put: (url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<any>;
20
+ delete: (url: string, body?: any, opts?: Pick<RequestOptions, "body" | "params" | "contentType" | "responseType" | "headers" | "credentials"> | undefined) => Promise<any>;
21
+ postDownload: (url: string, body?: any, params?: any, opts?: any) => Promise<any>;
22
+ extractHeadersFromOptions: (options?: UserJwtOptions) => {
23
+ Authorization?: string;
24
+ };
25
+ /** @deprecated use getContextBaseUrl instead */
26
+ static getBaseUrl: (context: ContextOptions, url: string, withFronteggPrefix?: boolean) => string;
27
+ /** @deprecated use getContextBaseUrl instead */
28
+ getBaseUrl: (context: ContextOptions, url: string, withFronteggPrefix?: boolean) => string;
29
+ getContextBaseUrl: (url: string, withFronteggPrefix?: boolean) => string;
30
+ static getMetadataHeaders: (context: ContextOptions) => Record<string, string>;
31
+ /** @deprecated - use getContextMetadataHeaders instead */
32
+ getMetadataHeaders: (context: ContextOptions) => Record<string, string>;
33
+ getContextMetadataHeaders: () => Record<string, string>;
34
+ static getScopedTenant: () => string | null;
35
+ }
36
+ declare const _default: FetchClient;
37
+ /**
38
+ * import FetchClient and use it to make requests to the server for specific application
39
+ * @param appName - the application name to make requests for
40
+ * @deprecated - use FetchClient directly
41
+ */
42
+ export default _default;