@frontegg/rest-api 3.1.73 → 3.1.74-alpha.9436511986

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 (125) hide show
  1. package/BaseApiClient.d.ts +16 -0
  2. package/BaseApiClient.js +39 -0
  3. package/ContextHolder/index.d.ts +81 -24
  4. package/ContextHolder/index.js +55 -43
  5. package/FetchClient.d.ts +35 -0
  6. package/FetchClient.js +286 -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 +764 -768
  14. package/auth/index.js +875 -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 +10 -9
  19. package/connectivity/index.d.ts +125 -26
  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 +174 -108
  32. package/index.js +108 -79
  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 +59 -44
  38. package/node/FetchClient.js +311 -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 +746 -1036
  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 +127 -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 +83 -73
  58. package/node/sub-tenants/interfaces.js +10 -1
  59. package/node/subscriptions/index.js +79 -107
  60. package/node/subscriptions/invoices.js +25 -17
  61. package/node/subscriptions/managedSubscriptions.js +32 -27
  62. package/node/subscriptions/paymentMethods.js +27 -20
  63. package/node/subscriptions/paymentProviders.js +15 -6
  64. package/node/subscriptions/plans.js +17 -9
  65. package/node/subscriptions/providers/stripe/index.js +26 -21
  66. package/node/subscriptions/subscriptions.js +32 -27
  67. package/node/subscriptions/summaries.js +15 -6
  68. package/node/subscriptions/tenantConfiguration.js +17 -9
  69. package/node/subscriptions/vendorPublicConfigurations.js +15 -6
  70. package/node/teams/index.js +130 -138
  71. package/node/tenants/index.js +65 -60
  72. package/node/user-phone-numbers/index.js +32 -24
  73. package/node/users/index.js +58 -53
  74. package/node/vendor/index.js +17 -6
  75. package/notifications/index.d.ts +22 -16
  76. package/notifications/index.js +33 -22
  77. package/package.json +1 -1
  78. package/reports/index.d.ts +50 -44
  79. package/reports/index.js +75 -62
  80. package/roles/index.d.ts +44 -38
  81. package/roles/index.js +57 -41
  82. package/security-center/index.d.ts +14 -2
  83. package/security-center/index.js +15 -6
  84. package/sub-tenants/index.d.ts +57 -14
  85. package/sub-tenants/index.js +88 -61
  86. package/sub-tenants/interfaces.d.ts +8 -0
  87. package/sub-tenants/interfaces.js +7 -1
  88. package/subscriptions/index.d.ts +56 -11
  89. package/subscriptions/index.js +68 -11
  90. package/subscriptions/invoices.d.ts +16 -13
  91. package/subscriptions/invoices.js +24 -14
  92. package/subscriptions/managedSubscriptions.d.ts +18 -15
  93. package/subscriptions/managedSubscriptions.js +33 -22
  94. package/subscriptions/paymentMethods.d.ts +16 -13
  95. package/subscriptions/paymentMethods.js +26 -17
  96. package/subscriptions/paymentProviders.d.ts +8 -5
  97. package/subscriptions/paymentProviders.js +11 -4
  98. package/subscriptions/plans.d.ts +11 -8
  99. package/subscriptions/plans.js +14 -6
  100. package/subscriptions/providers/stripe/index.d.ts +24 -21
  101. package/subscriptions/providers/stripe/index.js +27 -16
  102. package/subscriptions/subscriptions.d.ts +24 -21
  103. package/subscriptions/subscriptions.js +33 -22
  104. package/subscriptions/summaries.d.ts +7 -4
  105. package/subscriptions/summaries.js +10 -3
  106. package/subscriptions/tenantConfiguration.d.ts +6 -3
  107. package/subscriptions/tenantConfiguration.js +15 -7
  108. package/subscriptions/vendorPublicConfigurations.d.ts +5 -2
  109. package/subscriptions/vendorPublicConfigurations.js +11 -4
  110. package/teams/index.d.ts +35 -131
  111. package/teams/index.js +122 -93
  112. package/tenants/index.d.ts +25 -37
  113. package/tenants/index.js +63 -47
  114. package/user-phone-numbers/index.d.ts +32 -26
  115. package/user-phone-numbers/index.js +32 -19
  116. package/users/index.d.ts +21 -15
  117. package/users/index.js +60 -44
  118. package/vendor/index.d.ts +12 -6
  119. package/vendor/index.js +11 -4
  120. package/fetch.d.ts +0 -24
  121. package/fetch.js +0 -265
  122. package/node/fetch.js +0 -306
  123. package/node/subscriptions/providers/index.js +0 -18
  124. package/subscriptions/providers/index.d.ts +0 -1
  125. package/subscriptions/providers/index.js +0 -1
package/index.js CHANGED
@@ -1,93 +1,122 @@
1
- /** @license Frontegg v3.1.73
1
+ /** @license Frontegg v3.1.74-alpha.9436511986
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
5
5
  */
6
- import * as auth from "./auth";
7
- import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from "./auth";
8
- import * as teams from "./teams";
9
- import * as metadata from "./metadata";
10
- import * as reports from "./reports";
11
- import * as notifications from "./notifications";
12
- import * as audits from "./audits";
13
- import * as fetch from "./fetch";
14
- import * as connectivity from "./connectivity";
15
- import * as tenants from "./tenants";
16
- import * as accountSettings from "./account-settings";
17
- import * as roles from "./roles";
18
- import * as subscriptions from "./subscriptions";
19
- import * as applications from "./applications";
20
- import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from "./subscriptions";
21
- import { FronteggApiError } from "./error";
22
- import * as vendor from "./vendor";
23
- import * as subTenants from "./sub-tenants";
24
- import * as featureFlags from "./feature-flags";
25
- import * as directory from "./directory";
26
- import * as impersonate from "./impersonate";
27
- import * as groups from "./groups";
28
- import * as users from "./users";
29
- import * as entitlements from "./entitlements";
30
- import * as securityCenter from "./security-center";
31
- import * as userPhoneNumbers from "./user-phone-numbers";
32
- import { ContextHolder, FronteggContext } from "./ContextHolder";
33
- export * from "./interfaces";
34
- export * from "./auth/interfaces";
35
- export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction } from './auth';
36
- export * from "./teams/interfaces";
37
- export * from "./metadata/interfaces";
38
- export * from "./reports/interfaces";
39
- export * from "./connectivity/interfaces";
40
- export * from "./notifications/interfaces";
41
- export * from "./audits/interfaces";
42
- export * from "./tenants/interfaces";
43
- export * from "./account-settings/interfaces";
44
- export * from "./roles/interfaces";
45
- export * from "./subscriptions/interfaces";
46
- export * from "./vendor/interfaces";
47
- export * from "./sub-tenants/interfaces";
48
- export * from "./routers";
49
- export * from "./feature-flags/index";
50
- export * from "./feature-flags/interfaces";
51
- export * from "./directory/index";
52
- export * from "./directory/interfaces";
53
- export * from "./impersonate/interfaces";
54
- export * from "./groups/interfaces";
55
- export * from "./groups/enums";
56
- export * from "./users/interfaces";
57
- export * from "./entitlements/interfaces";
58
- export * from "./security-center/interfaces";
59
- export * from "./user-phone-numbers/interfaces";
60
- export * from "./applications/interfaces";
6
+ import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from './auth';
7
+ import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from './subscriptions';
8
+ import { FronteggApiError } from './error';
9
+ import fetch, { FetchClient } from './FetchClient';
10
+ import { ContextHolder, FronteggContext, getFronteggContext } from './ContextHolder';
11
+ import DefaultAuthenticationApi, { AuthenticationApi } from './auth';
12
+ import DefaultUsersApi, { UsersApi } from './users';
13
+ import DefaultTeamsApi, { TeamsApi } from './teams';
14
+ import DefaultMetadataApi, { MetadataApi } from './metadata';
15
+ import DefaultReportsApi, { ReportsApi } from './reports';
16
+ import DefaultConnectivityApi, { ConnectivityApi } from './connectivity';
17
+ import DefaultNotificationsApi, { NotificationsApi } from './notifications';
18
+ import DefaultAuditsApi, { AuditsApi } from './audits';
19
+ import DefaultTenantsApi, { TenantsApi } from './tenants';
20
+ import DefaultAccountSettingsApi, { AccountSettingsApi } from './account-settings';
21
+ import DefaultRolesApi, { RolesApi } from './roles';
22
+ import DefaultSubscriptionsApi, { SubscriptionsApi } from './subscriptions';
23
+ import DefaultVendorApi, { VendorApi } from './vendor';
24
+ import DefaultSubTenantsApi, { SubTenantsApi } from './sub-tenants';
25
+ import DefaultFeatureFlagsApi, { FeatureFlagsApi } from './feature-flags';
26
+ import DefaultDirectoryApi, { DirectoryApi } from './directory';
27
+ import DefaultImpersonateApi, { ImpersonateApi } from './impersonate';
28
+ import DefaultGroupsApi, { GroupsApi } from './groups';
29
+ import DefaultEntitlementsApi, { EntitlementsApi } from './entitlements';
30
+ import DefaultSecurityCenterApi, { SecurityCenterApi } from './security-center';
31
+ import DefaultPhoneNumbersApi, { PhoneNumbersApi } from './user-phone-numbers';
32
+ import DefaultApplicationsApi, { ApplicationsApi } from './applications';
33
+ export * from './interfaces';
34
+ export * from './auth/interfaces';
35
+ export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, removeTabTenantFromSessionStorage, getCurrentUserTenantsFunction, FRONTEGG_SEPARATE_TABS_BY_TENANT } from './auth';
36
+ export * from './teams/interfaces';
37
+ export * from './metadata/interfaces';
38
+ export * from './reports/interfaces';
39
+ export * from './connectivity/interfaces';
40
+ export * from './notifications/interfaces';
41
+ export * from './audits/interfaces';
42
+ export * from './tenants/interfaces';
43
+ export * from './account-settings/interfaces';
44
+ export * from './roles/interfaces';
45
+ export * from './subscriptions/interfaces';
46
+ export * from './vendor/interfaces';
47
+ export * from './sub-tenants/interfaces';
48
+ export * from './routers';
49
+ export * from './feature-flags/index';
50
+ export * from './feature-flags/interfaces';
51
+ export * from './directory/index';
52
+ export * from './directory/interfaces';
53
+ export * from './impersonate/interfaces';
54
+ export * from './groups/interfaces';
55
+ export * from './groups/enums';
56
+ export * from './users/interfaces';
57
+ export * from './entitlements/interfaces';
58
+ export * from './security-center/interfaces';
59
+ export * from './user-phone-numbers/interfaces';
60
+ export * from './applications/interfaces';
61
61
  const api = {
62
- auth,
63
- teams,
64
- metadata,
65
- reports,
66
- connectivity,
67
- notifications,
68
- audits,
69
- tenants,
70
- accountSettings,
71
- roles,
72
- subscriptions,
73
- vendor,
74
- subTenants,
75
- featureFlags,
76
- directory,
77
- impersonate,
78
- groups,
79
- users,
80
- entitlements,
81
- securityCenter,
82
- userPhoneNumbers,
83
- applications
62
+ auth: DefaultAuthenticationApi,
63
+ teams: DefaultTeamsApi,
64
+ metadata: DefaultMetadataApi,
65
+ reports: DefaultReportsApi,
66
+ connectivity: DefaultConnectivityApi,
67
+ notifications: DefaultNotificationsApi,
68
+ audits: DefaultAuditsApi,
69
+ tenants: DefaultTenantsApi,
70
+ accountSettings: DefaultAccountSettingsApi,
71
+ roles: DefaultRolesApi,
72
+ subscriptions: DefaultSubscriptionsApi,
73
+ vendor: DefaultVendorApi,
74
+ subTenants: DefaultSubTenantsApi,
75
+ featureFlags: DefaultFeatureFlagsApi,
76
+ directory: DefaultDirectoryApi,
77
+ impersonate: DefaultImpersonateApi,
78
+ groups: DefaultGroupsApi,
79
+ users: DefaultUsersApi,
80
+ entitlements: DefaultEntitlementsApi,
81
+ securityCenter: DefaultSecurityCenterApi,
82
+ userPhoneNumbers: DefaultPhoneNumbersApi,
83
+ applications: DefaultApplicationsApi
84
84
  };
85
- export { fetch, ContextHolder, FronteggContext, api, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy };
85
+
86
+ const createApiClient = appName => ({
87
+ auth: new AuthenticationApi(appName),
88
+ teams: new TeamsApi(appName),
89
+ metadata: new MetadataApi(appName),
90
+ reports: new ReportsApi(appName),
91
+ connectivity: new ConnectivityApi(appName),
92
+ notifications: new NotificationsApi(appName),
93
+ audits: new AuditsApi(appName),
94
+ tenants: new TenantsApi(appName),
95
+ accountSettings: new AccountSettingsApi(appName),
96
+ roles: new RolesApi(appName),
97
+ subscriptions: new SubscriptionsApi(appName),
98
+ vendor: new VendorApi(appName),
99
+ subTenants: new SubTenantsApi(appName),
100
+ featureFlags: new FeatureFlagsApi(appName),
101
+ directory: new DirectoryApi(appName),
102
+ impersonate: new ImpersonateApi(appName),
103
+ groups: new GroupsApi(appName),
104
+ users: new UsersApi(appName),
105
+ entitlements: new EntitlementsApi(appName),
106
+ securityCenter: new SecurityCenterApi(appName),
107
+ userPhoneNumbers: new PhoneNumbersApi(appName),
108
+ applications: new ApplicationsApi(appName)
109
+ });
110
+
111
+ export { fetch, ContextHolder, FronteggContext, getFronteggContext, api, createApiClient, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy };
86
112
  export default {
87
113
  fetch,
114
+ FetchClient,
88
115
  ContextHolder,
89
116
  FronteggContext,
117
+ getFronteggContext,
90
118
  api,
119
+ createApiClient,
91
120
  FronteggApiError,
92
121
  AuthStrategyEnum,
93
122
  MachineToMachineAuthStrategy,
package/interfaces.d.ts CHANGED
@@ -102,3 +102,13 @@ export declare enum PaginationOrderEnum {
102
102
  ASC = "ASC",
103
103
  DESC = "DESC"
104
104
  }
105
+ export interface RequestOptions {
106
+ url: string;
107
+ method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
108
+ body?: any;
109
+ params?: any;
110
+ contentType?: string;
111
+ responseType?: 'json' | 'plain' | 'blob';
112
+ headers?: Record<string, string>;
113
+ credentials?: RequestCredentials;
114
+ }
@@ -1,8 +1,68 @@
1
1
  import { CommitChangesRequest, IAuditsMetadata, IMetadataIp, INotificationMetadata, ISamlMetadata } from './interfaces';
2
- export declare function getAdminBoxMetadata(): Promise<any>;
3
- export declare function updateAdminBoxMetadata(body: CommitChangesRequest): Promise<any>;
4
- export declare function getCurrentUserIpMetadata(): Promise<IMetadataIp>;
5
- export declare const getNotificationsMetadata: () => Promise<INotificationMetadata>;
6
- export declare const getSamlMetadata: () => Promise<ISamlMetadata>;
7
- export declare const getAuditsMetadata: () => Promise<IAuditsMetadata>;
8
- export declare const getIpAdressMetadata: (ip: string) => Promise<IMetadataIp>;
2
+ import { BaseApiClient } from '../BaseApiClient';
3
+ export declare class MetadataApi extends BaseApiClient {
4
+ constructor(appName: string);
5
+ /**
6
+ * Retrieves metadata based on the given criteria.
7
+ *
8
+ * @param body - Metadata request parameters.
9
+ * @returns Metadata matching the criteria.
10
+ * @throws Will throw an error if metadata is not found.
11
+ */
12
+ private getMetadata;
13
+ /**
14
+ * Retrieves admin box metadata.
15
+ *
16
+ * @returns Admin box metadata.
17
+ */
18
+ getAdminBoxMetadata: () => Promise<unknown>;
19
+ /**
20
+ * Updates admin box metadata.
21
+ *
22
+ * @param body - Request body for committing changes.
23
+ * @returns Response from the POST request.
24
+ */
25
+ updateAdminBoxMetadata: (body: CommitChangesRequest) => Promise<unknown>;
26
+ /**
27
+ * Retrieves IP metadata for a given IP address.
28
+ *
29
+ * @param ip - IP address to get metadata for.
30
+ * @returns IP metadata.
31
+ * @throws Will throw an error if IP metadata is not found.
32
+ */
33
+ private getIpMetadata;
34
+ /**
35
+ * Retrieves current user IP metadata.
36
+ *
37
+ * @returns Current user IP metadata.
38
+ * @throws Will throw an error if IP metadata is not found.
39
+ */
40
+ getCurrentUserIpMetadata: () => Promise<IMetadataIp>;
41
+ /**
42
+ * Retrieves notifications metadata.
43
+ *
44
+ * @returns Notifications metadata.
45
+ */
46
+ getNotificationsMetadata: () => Promise<INotificationMetadata>;
47
+ /**
48
+ * Retrieves SAML metadata.
49
+ *
50
+ * @returns SAML metadata.
51
+ */
52
+ getSamlMetadata: () => Promise<ISamlMetadata>;
53
+ /**
54
+ * Retrieves audits metadata.
55
+ *
56
+ * @returns Audits metadata.
57
+ */
58
+ getAuditsMetadata: () => Promise<IAuditsMetadata>;
59
+ /**
60
+ * Retrieves IP address metadata for a given IP.
61
+ *
62
+ * @param ip - IP address to get metadata for.
63
+ * @returns IP address metadata.
64
+ */
65
+ getIpAdressMetadata: (ip: string) => Promise<IMetadataIp>;
66
+ }
67
+ declare const _default: MetadataApi;
68
+ export default _default;
package/metadata/index.js CHANGED
@@ -1,38 +1,58 @@
1
- import { Get, Post } from '../fetch';
1
+ import { BaseApiClient } from '../BaseApiClient';
2
+ export class MetadataApi extends BaseApiClient {
3
+ constructor(appName) {
4
+ super(appName);
2
5
 
3
- async function getMetadata(body) {
4
- var _data$rows, _data$rows2;
6
+ this.getMetadata = async body => {
7
+ var _data$rows, _data$rows2;
5
8
 
6
- const data = await Get('/metadata', body);
7
- if (data != null && (_data$rows = data.rows) != null && _data$rows[0]) return data == null ? void 0 : (_data$rows2 = data.rows) == null ? void 0 : _data$rows2[0];
8
- throw new Error(`metadata not found: ${body.entityName}`);
9
- }
9
+ const data = await this.get('/metadata', body);
10
+ if (data != null && (_data$rows = data.rows) != null && _data$rows[0]) return data == null ? void 0 : (_data$rows2 = data.rows) == null ? void 0 : _data$rows2[0];
11
+ throw new Error(`metadata not found: ${body.entityName}`);
12
+ };
10
13
 
11
- export async function getAdminBoxMetadata() {
12
- return Get('/metadata/admin-box');
13
- }
14
- export async function updateAdminBoxMetadata(body) {
15
- return Post('/metadata/admin-box', body);
16
- }
14
+ this.getAdminBoxMetadata = async () => {
15
+ return this.get('/metadata/admin-box');
16
+ };
17
17
 
18
- async function getIpMetadata(ip) {
19
- const data = await Get(`/metadata/ip/${ip}`);
20
- if (data) return data;
21
- throw new Error(`ip metadata not found`);
22
- }
18
+ this.updateAdminBoxMetadata = async body => {
19
+ return this.post('/metadata/admin-box', body);
20
+ };
21
+
22
+ this.getIpMetadata = async ip => {
23
+ const data = await this.get(`/metadata/ip/${ip}`);
24
+ if (data) return data;
25
+ throw new Error(`ip metadata not found`);
26
+ };
27
+
28
+ this.getCurrentUserIpMetadata = async () => {
29
+ const data = await this.get(`/metadata/ipme`);
30
+ if (data) return data;
31
+ throw new Error(`ip metadata not found`);
32
+ };
33
+
34
+ this.getNotificationsMetadata = async () => {
35
+ return this.getMetadata({
36
+ entityName: 'notifications'
37
+ });
38
+ };
39
+
40
+ this.getSamlMetadata = async () => {
41
+ return this.getMetadata({
42
+ entityName: 'saml'
43
+ });
44
+ };
45
+
46
+ this.getAuditsMetadata = async () => {
47
+ return this.getMetadata({
48
+ entityName: 'audits'
49
+ });
50
+ };
51
+
52
+ this.getIpAdressMetadata = async ip => {
53
+ return this.getIpMetadata(ip);
54
+ };
55
+ }
23
56
 
24
- export async function getCurrentUserIpMetadata() {
25
- const data = await Get(`/metadata/ipme`);
26
- if (data) return data;
27
- throw new Error(`ip metadata not found`);
28
57
  }
29
- export const getNotificationsMetadata = async () => getMetadata({
30
- entityName: 'notifications'
31
- });
32
- export const getSamlMetadata = async () => getMetadata({
33
- entityName: 'saml'
34
- });
35
- export const getAuditsMetadata = async () => getMetadata({
36
- entityName: 'audits'
37
- });
38
- export const getIpAdressMetadata = async ip => getIpMetadata(ip);
58
+ export default new MetadataApi('default');
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BaseApiClient = void 0;
7
+
8
+ var _FetchClient = require("./FetchClient");
9
+
10
+ class BaseApiClient {
11
+ constructor(appName) {
12
+ this.appName = void 0;
13
+ this.fetchClient = void 0;
14
+
15
+ this.get = async (url, params, opts) => {
16
+ return this.fetchClient.get(url, params, opts);
17
+ };
18
+
19
+ this.post = async (url, body, opts) => {
20
+ return this.fetchClient.post(url, body, opts);
21
+ };
22
+
23
+ this.patch = async (url, body, opts) => {
24
+ return this.fetchClient.patch(url, body, opts);
25
+ };
26
+
27
+ this.put = async (url, body, opts) => {
28
+ return this.fetchClient.put(url, body, opts);
29
+ };
30
+
31
+ this.delete = async (url, body, opts) => {
32
+ return this.fetchClient.delete(url, body, opts);
33
+ };
34
+
35
+ this.postDownload = async (url, body, params, opts) => {
36
+ return this.fetchClient.postDownload(url, body, params, opts);
37
+ };
38
+
39
+ this.extractHeadersFromOptions = (options = {}) => {
40
+ return this.fetchClient.extractHeadersFromOptions(options);
41
+ };
42
+
43
+ this.appName = appName;
44
+ this.fetchClient = new _FetchClient.FetchClient(appName);
45
+ }
46
+
47
+ }
48
+
49
+ exports.BaseApiClient = BaseApiClient;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.FronteggContext = exports.ContextHolder = void 0;
6
+ exports.getFronteggContext = exports.FronteggContext = exports.ContextHolder = void 0;
7
7
 
8
8
  class ContextHolder {
9
9
  constructor() {
@@ -21,107 +21,107 @@ class ContextHolder {
21
21
  this.sessionContext = void 0;
22
22
  }
23
23
 
24
- static getInstance() {
25
- if (!ContextHolder.instance) {
26
- ContextHolder.instance = new ContextHolder();
24
+ static getInstance(appName = 'default') {
25
+ if (ContextHolder._apps[appName]) {
26
+ return ContextHolder._apps[appName];
27
27
  }
28
28
 
29
- return ContextHolder.instance;
29
+ ContextHolder._apps[appName] = new ContextHolder();
30
+ return ContextHolder._apps[appName];
30
31
  }
31
32
 
32
- static setContext(context) {
33
- ContextHolder.getInstance().context = context;
33
+ static setContext(context, appName = 'default') {
34
+ ContextHolder.getInstance(appName).context = context;
34
35
  }
35
36
 
36
- static setAccessToken(accessToken) {
37
- ContextHolder.getInstance().accessToken = accessToken;
37
+ static setAccessToken(accessToken, appName = 'default') {
38
+ ContextHolder.getInstance(appName).accessToken = accessToken;
38
39
  }
39
40
 
40
- static setUser(user) {
41
- ContextHolder.getInstance().user = user;
41
+ static setUser(user, appName = 'default') {
42
+ ContextHolder.getInstance(appName).user = user;
42
43
  }
43
44
 
44
- static setRequestSource(requestSource) {
45
- ContextHolder.getInstance().requestSource = requestSource;
45
+ static setRequestSource(requestSource, appName = 'default') {
46
+ ContextHolder.getInstance(appName).requestSource = requestSource;
46
47
  }
47
48
 
48
- static setOnRedirectTo(onRedirectTo) {
49
- ContextHolder.getInstance().onRedirectTo = onRedirectTo;
49
+ static setOnRedirectTo(onRedirectTo, appName = 'default') {
50
+ ContextHolder.getInstance(appName).onRedirectTo = onRedirectTo;
50
51
  }
51
52
 
52
- static setLogout(logout, logoutUrl) {
53
- ContextHolder.getInstance().logout = callback => {
53
+ static setLogout(logout, logoutUrl, appName = 'default') {
54
+ ContextHolder.getInstance(appName).logout = callback => {
54
55
  if (!callback) {
55
- ContextHolder.onRedirectTo(logoutUrl);
56
+ ContextHolder.onRedirectTo(logoutUrl, undefined, appName);
56
57
  } else {
57
58
  logout(callback);
58
59
  }
59
60
  };
60
61
  }
61
62
 
62
- static setEntitlementsOptions(entitlementsOptions) {
63
- ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
63
+ static setEntitlementsOptions(entitlementsOptions, appName = 'default') {
64
+ ContextHolder.getInstance(appName).entitlementsOptions = entitlementsOptions;
64
65
  }
65
66
 
66
- static setSessionContext(sessionContext) {
67
- const instance = ContextHolder.getInstance();
68
- instance.sessionContext = sessionContext;
67
+ static setSessionContext(sessionContext, appName = 'default') {
68
+ ContextHolder.getInstance(appName).sessionContext = sessionContext;
69
69
  }
70
70
 
71
71
  static setAppName(appName) {
72
- ContextHolder.getInstance().appName = appName;
72
+ ContextHolder.getInstance(appName).appName = appName;
73
73
  }
74
74
 
75
- static getContext() {
75
+ static getContext(appName = 'default') {
76
76
  var _ContextHolder$getIns;
77
77
 
78
- return (_ContextHolder$getIns = ContextHolder.getInstance().context) != null ? _ContextHolder$getIns : {
78
+ return (_ContextHolder$getIns = ContextHolder.getInstance(appName).context) != null ? _ContextHolder$getIns : {
79
79
  baseUrl: window.location.href,
80
80
  tokenResolver: () => 'my-authentication-token',
81
81
  logLevel: 'error'
82
82
  };
83
83
  }
84
84
 
85
- static getAccessToken() {
86
- return ContextHolder.getInstance().accessToken;
85
+ static getAccessToken(appName = 'default') {
86
+ return ContextHolder.getInstance(appName).accessToken;
87
87
  }
88
88
 
89
- static getRequestSource() {
90
- return ContextHolder.getInstance().requestSource;
89
+ static getRequestSource(appName = 'default') {
90
+ return ContextHolder.getInstance(appName).requestSource;
91
91
  }
92
92
 
93
- static getUser() {
94
- return ContextHolder.getInstance().user;
93
+ static getUser(appName = 'default') {
94
+ return ContextHolder.getInstance(appName).user;
95
95
  }
96
96
 
97
- static onRedirectTo(path, opts) {
98
- return ContextHolder.getInstance().onRedirectTo(path, opts);
97
+ static onRedirectTo(path, opts, appName = 'default') {
98
+ return ContextHolder.getInstance(appName).onRedirectTo(path, opts);
99
99
  }
100
100
 
101
- static logout(callback) {
102
- return ContextHolder.getInstance().logout(callback);
101
+ static logout(callback, appName = 'default') {
102
+ return ContextHolder.getInstance(appName).logout(callback);
103
103
  }
104
104
 
105
- static shouldLoadEntitlements() {
105
+ static shouldLoadEntitlements(appName = 'default') {
106
106
  var _ContextHolder$getIns2;
107
107
 
108
- return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
108
+ return ((_ContextHolder$getIns2 = ContextHolder.getInstance(appName).entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
109
109
  }
110
110
 
111
- static isSessionPerTenantEnabled() {
111
+ static isSessionPerTenantEnabled(appName = 'default') {
112
112
  var _ContextHolder$getIns3;
113
113
 
114
- return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
114
+ return ((_ContextHolder$getIns3 = ContextHolder.getInstance(appName).sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
115
115
  }
116
116
 
117
- static getAppName() {
118
- return ContextHolder.getInstance().appName;
117
+ static getAppName(appName = 'default') {
118
+ return ContextHolder.getInstance(appName).appName;
119
119
  }
120
120
 
121
121
  }
122
122
 
123
123
  exports.ContextHolder = ContextHolder;
124
- ContextHolder.instance = void 0;
124
+ ContextHolder._apps = void 0;
125
125
  const FronteggContext = {
126
126
  getContext: () => ContextHolder.getContext(),
127
127
  getAccessToken: () => ContextHolder.getAccessToken(),
@@ -129,4 +129,19 @@ const FronteggContext = {
129
129
  onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts),
130
130
  logout: callback => ContextHolder.logout(callback)
131
131
  };
132
- exports.FronteggContext = FronteggContext;
132
+ exports.FronteggContext = FronteggContext;
133
+
134
+ const getFronteggContext = (appName = 'default') => ({
135
+ getContext: () => ContextHolder.getContext(appName),
136
+ getAccessToken: () => ContextHolder.getAccessToken(appName),
137
+ getUser: () => ContextHolder.getUser(appName),
138
+ onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts, appName),
139
+ logout: callback => ContextHolder.logout(callback, appName),
140
+ getRequestSource: () => ContextHolder.getRequestSource(appName),
141
+ setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, appName),
142
+ setUser: user => ContextHolder.setUser(user, appName),
143
+ isSessionPerTenantEnabled: () => ContextHolder.isSessionPerTenantEnabled(appName),
144
+ shouldLoadEntitlements: () => ContextHolder.shouldLoadEntitlements(appName)
145
+ });
146
+
147
+ exports.getFronteggContext = getFronteggContext;