@frontegg/rest-api 6.0.1-alpha.4 → 7.28.0-alpha.0

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 (218) hide show
  1. package/BaseApiClient.d.ts +16 -0
  2. package/BaseApiClient.js +30 -0
  3. package/ContextHolder/index.d.ts +160 -0
  4. package/ContextHolder/index.js +278 -0
  5. package/ContextHolder/package.json +6 -0
  6. package/FetchClient.d.ts +42 -0
  7. package/FetchClient.js +260 -0
  8. package/account-settings/index.d.ts +21 -7
  9. package/account-settings/index.js +25 -6
  10. package/account-settings/interfaces.d.ts +9 -2
  11. package/applications/index.d.ts +51 -0
  12. package/applications/index.js +55 -0
  13. package/applications/interfaces.d.ts +49 -0
  14. package/applications/interfaces.js +5 -0
  15. package/applications/package.json +6 -0
  16. package/audits/index.d.ts +27 -15
  17. package/audits/index.js +29 -16
  18. package/audits/interfaces.d.ts +3 -2
  19. package/auth/constants.d.ts +5 -0
  20. package/auth/constants.js +5 -0
  21. package/auth/enums.d.ts +8 -1
  22. package/auth/enums.js +9 -4
  23. package/auth/index.d.ts +833 -428
  24. package/auth/index.js +768 -385
  25. package/auth/interfaces.d.ts +341 -39
  26. package/auth/interfaces.js +19 -9
  27. package/auth/secutiry-poilicy/index.d.ts +60 -41
  28. package/auth/secutiry-poilicy/index.js +99 -45
  29. package/auth/secutiry-poilicy/interfaces.d.ts +62 -2
  30. package/auth/secutiry-poilicy/interfaces.js +5 -1
  31. package/auth/utils.d.ts +10 -0
  32. package/auth/utils.js +35 -0
  33. package/connectivity/index.d.ts +126 -27
  34. package/connectivity/index.js +120 -114
  35. package/constants.d.ts +115 -0
  36. package/constants.js +122 -5
  37. package/directory/index.d.ts +32 -0
  38. package/directory/index.js +30 -0
  39. package/directory/interfaces.d.ts +30 -0
  40. package/directory/interfaces.js +7 -0
  41. package/directory/package.json +6 -0
  42. package/entitlements/index.d.ts +15 -0
  43. package/entitlements/index.js +20 -0
  44. package/entitlements/interfaces.d.ts +13 -0
  45. package/entitlements/interfaces.js +11 -0
  46. package/entitlements/package.json +6 -0
  47. package/error.js +0 -2
  48. package/feature-flags/index.d.ts +18 -0
  49. package/feature-flags/index.js +44 -0
  50. package/feature-flags/interfaces.d.ts +5 -0
  51. package/feature-flags/interfaces.js +1 -0
  52. package/feature-flags/package.json +6 -0
  53. package/groups/enums.d.ts +9 -0
  54. package/groups/enums.js +11 -0
  55. package/groups/index.d.ts +73 -0
  56. package/groups/index.js +62 -0
  57. package/groups/interfaces.d.ts +64 -0
  58. package/groups/interfaces.js +1 -0
  59. package/groups/package.json +6 -0
  60. package/impersonate/index.d.ts +17 -0
  61. package/impersonate/index.js +23 -0
  62. package/impersonate/interfaces.d.ts +12 -0
  63. package/impersonate/interfaces.js +1 -0
  64. package/impersonate/package.json +6 -0
  65. package/index.d.ts +148 -53
  66. package/index.js +103 -31
  67. package/interfaces.d.ts +82 -1
  68. package/interfaces.js +28 -1
  69. package/jwt.js +19 -20
  70. package/metadata/index.d.ts +68 -5
  71. package/metadata/index.js +53 -23
  72. package/metadata/interfaces.d.ts +10 -2
  73. package/node/BaseApiClient.js +37 -0
  74. package/node/ContextHolder/index.js +286 -0
  75. package/node/FetchClient.js +268 -0
  76. package/node/account-settings/index.js +26 -11
  77. package/node/applications/index.js +62 -0
  78. package/node/applications/interfaces.js +12 -0
  79. package/node/audits/index.js +32 -27
  80. package/node/auth/constants.js +13 -0
  81. package/node/auth/enums.js +11 -5
  82. package/node/auth/index.js +807 -644
  83. package/node/auth/interfaces.js +27 -13
  84. package/node/auth/secutiry-poilicy/index.js +100 -66
  85. package/node/auth/secutiry-poilicy/interfaces.js +8 -1
  86. package/node/auth/utils.js +44 -0
  87. package/node/connectivity/index.js +123 -197
  88. package/node/constants.js +124 -6
  89. package/node/directory/index.js +37 -0
  90. package/node/directory/interfaces.js +14 -0
  91. package/node/entitlements/index.js +27 -0
  92. package/node/entitlements/interfaces.js +18 -0
  93. package/node/error.js +0 -4
  94. package/node/feature-flags/index.js +54 -0
  95. package/node/feature-flags/interfaces.js +5 -0
  96. package/node/groups/enums.js +19 -0
  97. package/node/groups/index.js +70 -0
  98. package/node/groups/interfaces.js +5 -0
  99. package/node/impersonate/index.js +29 -0
  100. package/node/impersonate/interfaces.js +5 -0
  101. package/node/index.js +324 -94
  102. package/node/interfaces.js +34 -1
  103. package/node/jwt.js +19 -25
  104. package/node/metadata/index.js +57 -38
  105. package/node/notifications/index.js +34 -31
  106. package/node/reports/index.js +79 -83
  107. package/node/roles/index.js +55 -60
  108. package/node/roles/interfaces.js +9 -1
  109. package/node/routers.js +52 -6
  110. package/node/security-center/index.js +26 -0
  111. package/node/security-center/interfaces.js +74 -0
  112. package/node/sub-tenants/index.js +82 -29
  113. package/node/sub-tenants/interfaces.js +9 -1
  114. package/node/subscriptions/enums.js +13 -9
  115. package/node/subscriptions/index.js +64 -109
  116. package/node/subscriptions/interfaces.js +0 -2
  117. package/node/subscriptions/invoices.js +20 -21
  118. package/node/subscriptions/managedSubscriptions.js +28 -33
  119. package/node/subscriptions/paymentMethods.js +23 -27
  120. package/node/subscriptions/paymentProviders.js +11 -8
  121. package/node/subscriptions/plans.js +13 -12
  122. package/node/subscriptions/providers/stripe/index.js +22 -27
  123. package/node/subscriptions/subscriptions.js +28 -33
  124. package/node/subscriptions/summaries.js +11 -8
  125. package/node/subscriptions/tenantConfiguration.js +13 -12
  126. package/node/subscriptions/vendorPublicConfigurations.js +17 -0
  127. package/node/teams/index.js +108 -121
  128. package/node/teams/interfaces.js +8 -1
  129. package/node/tenants/index.js +63 -21
  130. package/node/tenants/interfaces.js +18 -1
  131. package/node/user-phone-numbers/index.js +38 -0
  132. package/node/user-phone-numbers/interfaces.js +5 -0
  133. package/node/users/index.js +64 -0
  134. package/node/users/interfaces.js +27 -0
  135. package/node/velo/index.js +75 -0
  136. package/node/velo/interfaces.js +5 -0
  137. package/node/vendor/index.js +16 -8
  138. package/notifications/index.d.ts +22 -16
  139. package/notifications/index.js +33 -22
  140. package/package.json +4 -2
  141. package/reports/index.d.ts +50 -44
  142. package/reports/index.js +77 -68
  143. package/reports/interfaces.d.ts +2 -2
  144. package/roles/index.d.ts +45 -34
  145. package/roles/index.js +52 -41
  146. package/roles/interfaces.d.ts +25 -9
  147. package/roles/interfaces.js +6 -1
  148. package/routers.d.ts +6 -1
  149. package/routers.js +45 -2
  150. package/security-center/index.d.ts +15 -0
  151. package/security-center/index.js +19 -0
  152. package/security-center/interfaces.d.ts +115 -0
  153. package/security-center/interfaces.js +63 -0
  154. package/security-center/package.json +6 -0
  155. package/sub-tenants/index.d.ts +57 -8
  156. package/sub-tenants/index.js +84 -19
  157. package/sub-tenants/interfaces.d.ts +68 -10
  158. package/sub-tenants/interfaces.js +6 -1
  159. package/subscriptions/enums.d.ts +7 -0
  160. package/subscriptions/enums.js +10 -8
  161. package/subscriptions/index.d.ts +55 -9
  162. package/subscriptions/index.js +56 -9
  163. package/subscriptions/interfaces.d.ts +7 -3
  164. package/subscriptions/interfaces.js +1 -1
  165. package/subscriptions/invoices.d.ts +16 -13
  166. package/subscriptions/invoices.js +19 -14
  167. package/subscriptions/managedSubscriptions.d.ts +18 -15
  168. package/subscriptions/managedSubscriptions.js +27 -22
  169. package/subscriptions/paymentMethods.d.ts +16 -13
  170. package/subscriptions/paymentMethods.js +22 -18
  171. package/subscriptions/paymentProviders.d.ts +8 -5
  172. package/subscriptions/paymentProviders.js +9 -4
  173. package/subscriptions/plans.d.ts +11 -8
  174. package/subscriptions/plans.js +11 -6
  175. package/subscriptions/providers/stripe/index.d.ts +24 -21
  176. package/subscriptions/providers/stripe/index.js +21 -16
  177. package/subscriptions/subscriptions.d.ts +24 -21
  178. package/subscriptions/subscriptions.js +27 -22
  179. package/subscriptions/summaries.d.ts +7 -4
  180. package/subscriptions/summaries.js +8 -3
  181. package/subscriptions/tenantConfiguration.d.ts +6 -3
  182. package/subscriptions/tenantConfiguration.js +12 -7
  183. package/subscriptions/vendorPublicConfigurations.d.ts +5 -0
  184. package/subscriptions/vendorPublicConfigurations.js +10 -0
  185. package/teams/index.d.ts +38 -115
  186. package/teams/index.js +105 -79
  187. package/teams/interfaces.d.ts +47 -42
  188. package/teams/interfaces.js +5 -1
  189. package/tenants/index.d.ts +25 -26
  190. package/tenants/index.js +61 -12
  191. package/tenants/interfaces.d.ts +85 -0
  192. package/tenants/interfaces.js +14 -1
  193. package/user-phone-numbers/index.d.ts +32 -0
  194. package/user-phone-numbers/index.js +31 -0
  195. package/user-phone-numbers/interfaces.d.ts +32 -0
  196. package/user-phone-numbers/interfaces.js +1 -0
  197. package/user-phone-numbers/package.json +6 -0
  198. package/users/index.d.ts +24 -0
  199. package/users/index.js +55 -0
  200. package/users/interfaces.d.ts +144 -0
  201. package/users/interfaces.js +18 -0
  202. package/users/package.json +6 -0
  203. package/velo/index.d.ts +46 -0
  204. package/velo/index.js +68 -0
  205. package/velo/interfaces.d.ts +108 -0
  206. package/velo/interfaces.js +1 -0
  207. package/velo/package.json +6 -0
  208. package/vendor/index.d.ts +12 -6
  209. package/vendor/index.js +15 -4
  210. package/ContextHolder.d.ts +0 -29
  211. package/ContextHolder.js +0 -80
  212. package/fetch.d.ts +0 -19
  213. package/fetch.js +0 -203
  214. package/node/ContextHolder.js +0 -90
  215. package/node/fetch.js +0 -234
  216. package/node/subscriptions/providers/index.js +0 -18
  217. package/subscriptions/providers/index.d.ts +0 -1
  218. package/subscriptions/providers/index.js +0 -1
package/index.d.ts CHANGED
@@ -1,21 +1,36 @@
1
- import * as auth from './auth';
2
- import * as teams from './teams';
3
- import * as metadata from './metadata';
4
- import * as reports from './reports';
5
- import * as notifications from './notifications';
6
- import * as audits from './audits';
7
- import * as fetch from './fetch';
8
- import * as connectivity from './connectivity';
9
- import * as tenants from './tenants';
10
- import * as accountSettings from './account-settings';
11
- import * as roles from './roles';
12
- import * as subscriptions from './subscriptions';
1
+ import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from './auth';
2
+ import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from './subscriptions';
13
3
  import { FronteggApiError } from './error';
14
- import * as vendor from './vendor';
15
- import * as subTenants from './sub-tenants';
4
+ import fetch, { FetchClient } from './FetchClient';
16
5
  import { ContextHolder, FronteggContext } from './ContextHolder';
6
+ import { AuthenticationApi } from './auth';
7
+ import { SecurityPolicyApi } from './auth/secutiry-poilicy';
8
+ import { UsersApi } from './users';
9
+ import { TeamsApi } from './teams';
10
+ import { MetadataApi } from './metadata';
11
+ import { ReportsApi } from './reports';
12
+ import { ConnectivityApi } from './connectivity';
13
+ import { NotificationsApi } from './notifications';
14
+ import { AuditsApi } from './audits';
15
+ import { TenantsApi } from './tenants';
16
+ import { AccountSettingsApi } from './account-settings';
17
+ import { RolesApi } from './roles';
18
+ import { SubscriptionsApi } from './subscriptions';
19
+ import { VendorApi } from './vendor';
20
+ import { SubTenantsApi } from './sub-tenants';
21
+ import { FeatureFlagsApi } from './feature-flags';
22
+ import { DirectoryApi } from './directory';
23
+ import { ImpersonateApi } from './impersonate';
24
+ import { GroupsApi } from './groups';
25
+ import { EntitlementsApi } from './entitlements';
26
+ import { SecurityCenterApi } from './security-center';
27
+ import { PhoneNumbersApi } from './user-phone-numbers';
28
+ import { ApplicationsApi } from './applications';
29
+ import { VeloApi } from './velo';
17
30
  export * from './interfaces';
18
31
  export * from './auth/interfaces';
32
+ export * from './auth/enums';
33
+ export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, removeTabTenantFromSessionStorage, getCurrentUserTenantsFunction, FRONTEGG_SEPARATE_TABS_BY_TENANT, } from './auth';
19
34
  export * from './teams/interfaces';
20
35
  export * from './metadata/interfaces';
21
36
  export * from './reports/interfaces';
@@ -29,55 +44,135 @@ export * from './subscriptions/interfaces';
29
44
  export * from './vendor/interfaces';
30
45
  export * from './sub-tenants/interfaces';
31
46
  export * from './routers';
32
- import { AuthStrategyEnum, SocialLoginProviders } from './auth';
33
- import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from './subscriptions';
47
+ export * from './feature-flags/index';
48
+ export * from './feature-flags/interfaces';
49
+ export * from './directory/index';
50
+ export * from './directory/interfaces';
51
+ export * from './impersonate/interfaces';
52
+ export * from './groups/interfaces';
53
+ export * from './groups/enums';
54
+ export * from './users/interfaces';
55
+ export * from './entitlements/interfaces';
56
+ export * from './security-center/interfaces';
57
+ export * from './user-phone-numbers/interfaces';
58
+ export * from './applications/interfaces';
59
+ export * from './velo/interfaces';
60
+ /**
61
+ * Frontegg API client for default app
62
+ *
63
+ * @deprecated use createApiClient instead
64
+ */
34
65
  declare const api: {
35
- auth: typeof auth;
36
- teams: typeof teams;
37
- metadata: typeof metadata;
38
- reports: typeof reports;
39
- connectivity: typeof connectivity;
40
- notifications: typeof notifications;
41
- audits: typeof audits;
42
- tenants: typeof tenants;
43
- accountSettings: typeof accountSettings;
44
- roles: typeof roles;
45
- subscriptions: typeof subscriptions;
46
- vendor: typeof vendor;
47
- subTenants: typeof subTenants;
66
+ auth: AuthenticationApi;
67
+ securityPolicy: SecurityPolicyApi;
68
+ teams: TeamsApi;
69
+ metadata: MetadataApi;
70
+ reports: ReportsApi;
71
+ connectivity: ConnectivityApi;
72
+ notifications: NotificationsApi;
73
+ audits: AuditsApi;
74
+ tenants: TenantsApi;
75
+ accountSettings: AccountSettingsApi;
76
+ roles: RolesApi;
77
+ subscriptions: SubscriptionsApi;
78
+ vendor: VendorApi;
79
+ subTenants: SubTenantsApi;
80
+ featureFlags: FeatureFlagsApi;
81
+ directory: DirectoryApi;
82
+ impersonate: ImpersonateApi;
83
+ groups: GroupsApi;
84
+ users: UsersApi;
85
+ entitlements: EntitlementsApi;
86
+ securityCenter: SecurityCenterApi;
87
+ userPhoneNumbers: PhoneNumbersApi;
88
+ applications: ApplicationsApi;
89
+ velo: VeloApi;
90
+ };
91
+ export type FronteggApiClient = {
92
+ auth: AuthenticationApi;
93
+ securityPolicy: SecurityPolicyApi;
94
+ teams: TeamsApi;
95
+ metadata: MetadataApi;
96
+ reports: ReportsApi;
97
+ connectivity: ConnectivityApi;
98
+ notifications: NotificationsApi;
99
+ audits: AuditsApi;
100
+ tenants: TenantsApi;
101
+ accountSettings: AccountSettingsApi;
102
+ roles: RolesApi;
103
+ subscriptions: SubscriptionsApi;
104
+ vendor: VendorApi;
105
+ subTenants: SubTenantsApi;
106
+ featureFlags: FeatureFlagsApi;
107
+ directory: DirectoryApi;
108
+ impersonate: ImpersonateApi;
109
+ groups: GroupsApi;
110
+ users: UsersApi;
111
+ entitlements: EntitlementsApi;
112
+ securityCenter: SecurityCenterApi;
113
+ userPhoneNumbers: PhoneNumbersApi;
114
+ applications: ApplicationsApi;
115
+ velo: VeloApi;
48
116
  };
49
- export { fetch, ContextHolder, FronteggContext, api, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, };
117
+ declare const createApiClient: (appName: string) => FronteggApiClient;
118
+ export { fetch, FetchClient, ContextHolder, FronteggContext, api, createApiClient, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy, };
50
119
  declare const _default: {
51
- fetch: typeof fetch;
120
+ fetch: FetchClient;
121
+ FetchClient: typeof FetchClient;
52
122
  ContextHolder: typeof ContextHolder;
53
123
  FronteggContext: {
54
124
  getContext: () => import("./interfaces").ContextOptions;
55
125
  getAccessToken: () => string | null;
56
- getUser: () => import("./teams/interfaces").IUserProfile | null;
57
- onRedirectTo: (path: string, opts: import("./interfaces").RedirectOptions) => void;
58
- logout: (callback?: (() => void) | undefined) => void;
126
+ setAccessToken: (accessToken: string | null) => void;
127
+ getUser: () => import("./users/interfaces").IUserProfile | null;
128
+ setUser: (user: import("./users/interfaces").IUserProfile | null) => void;
129
+ onRedirectTo: (path: string, opts?: import("./interfaces").RedirectOptions) => void;
130
+ setOnRedirectTo: (onRedirectTo: (path: string, opts?: import("./interfaces").RedirectOptions) => void) => void;
131
+ logout: (callback?: () => void) => void;
132
+ getRequestSource: () => import("./interfaces").RequestSource | null;
133
+ setRequestSource: (requestSource: import("./interfaces").RequestSource | null) => void;
134
+ isSessionPerTenantEnabled: () => boolean;
135
+ shouldLoadEntitlements: () => boolean;
136
+ getAppName: () => string | null;
137
+ setEntitlementsOptions: (entitlementsOptions: import("./ContextHolder").EntitlementsOptions) => void;
138
+ setSessionContext: (sessionContext: import("./interfaces").SessionContext) => void;
139
+ getBasename: () => string | null;
140
+ setBasename: (basename: string | null) => void;
59
141
  };
60
142
  api: {
61
- auth: typeof auth;
62
- teams: typeof teams;
63
- metadata: typeof metadata;
64
- reports: typeof reports;
65
- connectivity: typeof connectivity;
66
- notifications: typeof notifications;
67
- audits: typeof audits;
68
- tenants: typeof tenants;
69
- accountSettings: typeof accountSettings;
70
- roles: typeof roles;
71
- subscriptions: typeof subscriptions;
72
- vendor: typeof vendor;
73
- subTenants: typeof subTenants;
143
+ auth: AuthenticationApi;
144
+ securityPolicy: SecurityPolicyApi;
145
+ teams: TeamsApi;
146
+ metadata: MetadataApi;
147
+ reports: ReportsApi;
148
+ connectivity: ConnectivityApi;
149
+ notifications: NotificationsApi;
150
+ audits: AuditsApi;
151
+ tenants: TenantsApi;
152
+ accountSettings: AccountSettingsApi;
153
+ roles: RolesApi;
154
+ subscriptions: SubscriptionsApi;
155
+ vendor: VendorApi;
156
+ subTenants: SubTenantsApi;
157
+ featureFlags: FeatureFlagsApi;
158
+ directory: DirectoryApi;
159
+ impersonate: ImpersonateApi;
160
+ groups: GroupsApi;
161
+ users: UsersApi;
162
+ entitlements: EntitlementsApi;
163
+ securityCenter: SecurityCenterApi;
164
+ userPhoneNumbers: PhoneNumbersApi;
165
+ applications: ApplicationsApi;
166
+ velo: VeloApi;
74
167
  };
168
+ createApiClient: (appName: string) => FronteggApiClient;
75
169
  FronteggApiError: typeof FronteggApiError;
76
- AuthStrategyEnum: typeof auth.AuthStrategyEnum;
77
- SocialLoginProviders: typeof auth.SocialLoginProviders;
78
- ISubscriptionCancellationPolicy: typeof subscriptions.ISubscriptionCancellationPolicy;
79
- ISubscriptionStatus: typeof subscriptions.ISubscriptionStatus;
80
- PaymentMethodType: typeof subscriptions.PaymentMethodType;
81
- ProviderType: typeof subscriptions.ProviderType;
170
+ AuthStrategyEnum: typeof AuthStrategyEnum;
171
+ MachineToMachineAuthStrategy: typeof MachineToMachineAuthStrategy;
172
+ SocialLoginProviders: typeof SocialLoginProviders;
173
+ ISubscriptionCancellationPolicy: typeof ISubscriptionCancellationPolicy;
174
+ ISubscriptionStatus: typeof ISubscriptionStatus;
175
+ PaymentMethodType: typeof PaymentMethodType;
176
+ ProviderType: typeof ProviderType;
82
177
  };
83
178
  export default _default;
package/index.js CHANGED
@@ -1,26 +1,41 @@
1
- /** @license Frontegg v6.0.1-alpha.4
1
+ /** @license Frontegg v7.28.0-alpha.0
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 * as teams from './teams';
8
- import * as metadata from './metadata';
9
- import * as reports from './reports';
10
- import * as notifications from './notifications';
11
- import * as audits from './audits';
12
- import * as fetch from './fetch';
13
- import * as connectivity from './connectivity';
14
- import * as tenants from './tenants';
15
- import * as accountSettings from './account-settings';
16
- import * as roles from './roles';
17
- import * as subscriptions from './subscriptions';
6
+ import { AuthStrategyEnum, MachineToMachineAuthStrategy, SocialLoginProviders } from './auth';
7
+ import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from './subscriptions';
18
8
  import { FronteggApiError } from './error';
19
- import * as vendor from './vendor';
20
- import * as subTenants from './sub-tenants';
9
+ import fetch, { FetchClient } from './FetchClient';
21
10
  import { ContextHolder, FronteggContext } from './ContextHolder';
11
+ import DefaultAuthenticationApi, { AuthenticationApi } from './auth';
12
+ import DefaultSecurityPolicyApi, { SecurityPolicyApi } from './auth/secutiry-poilicy';
13
+ import DefaultUsersApi, { UsersApi } from './users';
14
+ import DefaultTeamsApi, { TeamsApi } from './teams';
15
+ import DefaultMetadataApi, { MetadataApi } from './metadata';
16
+ import DefaultReportsApi, { ReportsApi } from './reports';
17
+ import DefaultConnectivityApi, { ConnectivityApi } from './connectivity';
18
+ import DefaultNotificationsApi, { NotificationsApi } from './notifications';
19
+ import DefaultAuditsApi, { AuditsApi } from './audits';
20
+ import DefaultTenantsApi, { TenantsApi } from './tenants';
21
+ import DefaultAccountSettingsApi, { AccountSettingsApi } from './account-settings';
22
+ import DefaultRolesApi, { RolesApi } from './roles';
23
+ import DefaultSubscriptionsApi, { SubscriptionsApi } from './subscriptions';
24
+ import DefaultVendorApi, { VendorApi } from './vendor';
25
+ import DefaultSubTenantsApi, { SubTenantsApi } from './sub-tenants';
26
+ import DefaultFeatureFlagsApi, { FeatureFlagsApi } from './feature-flags';
27
+ import DefaultDirectoryApi, { DirectoryApi } from './directory';
28
+ import DefaultImpersonateApi, { ImpersonateApi } from './impersonate';
29
+ import DefaultGroupsApi, { GroupsApi } from './groups';
30
+ import DefaultEntitlementsApi, { EntitlementsApi } from './entitlements';
31
+ import DefaultSecurityCenterApi, { SecurityCenterApi } from './security-center';
32
+ import DefaultPhoneNumbersApi, { PhoneNumbersApi } from './user-phone-numbers';
33
+ import DefaultApplicationsApi, { ApplicationsApi } from './applications';
34
+ import DefaultVeloApi, { VeloApi } from './velo';
22
35
  export * from './interfaces';
23
36
  export * from './auth/interfaces';
37
+ export * from './auth/enums';
38
+ export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, removeTabTenantFromSessionStorage, getCurrentUserTenantsFunction, FRONTEGG_SEPARATE_TABS_BY_TENANT } from './auth';
24
39
  export * from './teams/interfaces';
25
40
  export * from './metadata/interfaces';
26
41
  export * from './reports/interfaces';
@@ -34,31 +49,88 @@ export * from './subscriptions/interfaces';
34
49
  export * from './vendor/interfaces';
35
50
  export * from './sub-tenants/interfaces';
36
51
  export * from './routers';
37
- import { AuthStrategyEnum, SocialLoginProviders } from './auth';
38
- import { ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType } from './subscriptions';
52
+ export * from './feature-flags/index';
53
+ export * from './feature-flags/interfaces';
54
+ export * from './directory/index';
55
+ export * from './directory/interfaces';
56
+ export * from './impersonate/interfaces';
57
+ export * from './groups/interfaces';
58
+ export * from './groups/enums';
59
+ export * from './users/interfaces';
60
+ export * from './entitlements/interfaces';
61
+ export * from './security-center/interfaces';
62
+ export * from './user-phone-numbers/interfaces';
63
+ export * from './applications/interfaces';
64
+ export * from './velo/interfaces';
65
+
66
+ /**
67
+ * Frontegg API client for default app
68
+ *
69
+ * @deprecated use createApiClient instead
70
+ */
39
71
  const api = {
40
- auth,
41
- teams,
42
- metadata,
43
- reports,
44
- connectivity,
45
- notifications,
46
- audits,
47
- tenants,
48
- accountSettings,
49
- roles,
50
- subscriptions,
51
- vendor,
52
- subTenants
72
+ auth: DefaultAuthenticationApi,
73
+ securityPolicy: DefaultSecurityPolicyApi,
74
+ teams: DefaultTeamsApi,
75
+ metadata: DefaultMetadataApi,
76
+ reports: DefaultReportsApi,
77
+ connectivity: DefaultConnectivityApi,
78
+ notifications: DefaultNotificationsApi,
79
+ audits: DefaultAuditsApi,
80
+ tenants: DefaultTenantsApi,
81
+ accountSettings: DefaultAccountSettingsApi,
82
+ roles: DefaultRolesApi,
83
+ subscriptions: DefaultSubscriptionsApi,
84
+ vendor: DefaultVendorApi,
85
+ subTenants: DefaultSubTenantsApi,
86
+ featureFlags: DefaultFeatureFlagsApi,
87
+ directory: DefaultDirectoryApi,
88
+ impersonate: DefaultImpersonateApi,
89
+ groups: DefaultGroupsApi,
90
+ users: DefaultUsersApi,
91
+ entitlements: DefaultEntitlementsApi,
92
+ securityCenter: DefaultSecurityCenterApi,
93
+ userPhoneNumbers: DefaultPhoneNumbersApi,
94
+ applications: DefaultApplicationsApi,
95
+ velo: DefaultVeloApi
53
96
  };
54
- export { fetch, ContextHolder, FronteggContext, api, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType };
97
+ const createApiClient = appName => ({
98
+ auth: new AuthenticationApi(appName),
99
+ securityPolicy: new SecurityPolicyApi(appName),
100
+ teams: new TeamsApi(appName),
101
+ metadata: new MetadataApi(appName),
102
+ reports: new ReportsApi(appName),
103
+ connectivity: new ConnectivityApi(appName),
104
+ notifications: new NotificationsApi(appName),
105
+ audits: new AuditsApi(appName),
106
+ tenants: new TenantsApi(appName),
107
+ accountSettings: new AccountSettingsApi(appName),
108
+ roles: new RolesApi(appName),
109
+ subscriptions: new SubscriptionsApi(appName),
110
+ vendor: new VendorApi(appName),
111
+ subTenants: new SubTenantsApi(appName),
112
+ featureFlags: new FeatureFlagsApi(appName),
113
+ directory: new DirectoryApi(appName),
114
+ impersonate: new ImpersonateApi(appName),
115
+ groups: new GroupsApi(appName),
116
+ users: new UsersApi(appName),
117
+ entitlements: new EntitlementsApi(appName),
118
+ securityCenter: new SecurityCenterApi(appName),
119
+ userPhoneNumbers: new PhoneNumbersApi(appName),
120
+ applications: new ApplicationsApi(appName),
121
+ velo: new VeloApi(appName)
122
+ });
123
+ export { fetch, FetchClient, ContextHolder, FronteggContext, api, createApiClient, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy };
55
124
  export default {
56
125
  fetch,
126
+ FetchClient,
57
127
  ContextHolder,
58
128
  FronteggContext,
59
129
  api,
130
+ createApiClient,
60
131
  FronteggApiError,
61
132
  AuthStrategyEnum,
133
+ MachineToMachineAuthStrategy,
62
134
  SocialLoginProviders,
63
135
  ISubscriptionCancellationPolicy,
64
136
  ISubscriptionStatus,
package/interfaces.d.ts CHANGED
@@ -6,15 +6,78 @@ export interface PaginationResult<T> {
6
6
  totalPages: number;
7
7
  items: T[];
8
8
  }
9
+ export interface FronteggPaginationLinks {
10
+ next: string;
11
+ prev: string;
12
+ first: string;
13
+ last: string;
14
+ }
15
+ export interface FronteggPaginationResult<T> {
16
+ _metadata: {
17
+ totalPages: number;
18
+ totalItems: number;
19
+ };
20
+ items: T[];
21
+ }
22
+ export interface FronteggPaginationWrapper<T> extends FronteggPaginationResult<T> {
23
+ _links?: FronteggPaginationLinks;
24
+ }
9
25
  export interface KeyValuePair {
10
26
  key: string;
11
27
  value: string;
12
28
  }
13
- export declare type LogLevel = 'warn' | 'error';
29
+ export interface ResolvedTenantResult {
30
+ tenant?: string | null;
31
+ }
32
+ export type LogLevel = 'warn' | 'error';
33
+ export declare const fronteggHeaders: {
34
+ frameWork: string;
35
+ fronteggSdkVersion: string;
36
+ contentType: string;
37
+ source: string;
38
+ scopedTenant: string;
39
+ };
40
+ export declare enum RequestSource {
41
+ AdminPortal = "admin-portal",
42
+ LoginBox = "login-box"
43
+ }
44
+ export declare enum FronteggFrameworks {
45
+ Nextjs = "nextjs",
46
+ React = "react",
47
+ Angular = "angular",
48
+ Vuejs = "vuejs",
49
+ Flutter = "flutter",
50
+ Ios = "ios",
51
+ Android = "android",
52
+ Vanillajs = "vanillajs"
53
+ }
54
+ export interface MetadataHeaders {
55
+ framework?: FronteggFrameworks;
56
+ fronteggSdkVersion?: string;
57
+ }
58
+ export interface SessionContext {
59
+ enableSessionPerTenant?: boolean;
60
+ }
14
61
  export interface ContextOptions {
15
62
  baseUrl: string | ((url: string) => string);
16
63
  clientId?: string;
64
+ /**
65
+ * Will be used to identify the application, use only for multi applications
66
+ */
67
+ appId?: string;
17
68
  tokenResolver?: () => Promise<string> | string;
69
+ /**
70
+ * custom login header value
71
+ * @returns `{ tenant: string | null }`
72
+ */
73
+ tenantResolver?: () => Promise<ResolvedTenantResult> | ResolvedTenantResult;
74
+ /**
75
+ *
76
+ * @param opts all modifiable request options (RequestOptions)
77
+ * @param url url to be called, non-modifiable
78
+ * @returns RequestOptions
79
+ */
80
+ beforeRequestInterceptor?: (opts: Omit<RequestOptions, 'url'>, url: string) => RequestOptions;
18
81
  additionalQueryParamsResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
19
82
  additionalHeadersResolver?: () => Promise<KeyValuePair[]> | KeyValuePair[];
20
83
  currentUserRoles?: string[];
@@ -24,6 +87,7 @@ export interface ContextOptions {
24
87
  auditsOptions?: {
25
88
  virtualScroll?: boolean;
26
89
  };
90
+ metadataHeaders?: MetadataHeaders;
27
91
  }
28
92
  export interface QuerySort {
29
93
  id: string;
@@ -38,3 +102,20 @@ export interface RedirectOptions {
38
102
  replace?: boolean;
39
103
  preserveQueryParams?: boolean;
40
104
  }
105
+ export interface UserJwtOptions {
106
+ jwt?: string;
107
+ }
108
+ export declare enum PaginationOrderEnum {
109
+ ASC = "ASC",
110
+ DESC = "DESC"
111
+ }
112
+ export interface RequestOptions {
113
+ url: string;
114
+ method: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
115
+ body?: any;
116
+ params?: any;
117
+ contentType?: string;
118
+ responseType?: 'json' | 'plain' | 'blob' | 'stream';
119
+ headers?: Record<string, string>;
120
+ credentials?: RequestCredentials;
121
+ }
package/interfaces.js CHANGED
@@ -1 +1,28 @@
1
- export {};
1
+ export const fronteggHeaders = {
2
+ frameWork: 'x-frontegg-framework',
3
+ fronteggSdkVersion: 'x-frontegg-sdk',
4
+ contentType: 'Content-Type',
5
+ source: 'frontegg-source',
6
+ scopedTenant: 'frontegg-scoped-tenant'
7
+ };
8
+ export let RequestSource;
9
+ (function (RequestSource) {
10
+ RequestSource["AdminPortal"] = "admin-portal";
11
+ RequestSource["LoginBox"] = "login-box";
12
+ })(RequestSource || (RequestSource = {}));
13
+ export let FronteggFrameworks;
14
+ (function (FronteggFrameworks) {
15
+ FronteggFrameworks["Nextjs"] = "nextjs";
16
+ FronteggFrameworks["React"] = "react";
17
+ FronteggFrameworks["Angular"] = "angular";
18
+ FronteggFrameworks["Vuejs"] = "vuejs";
19
+ FronteggFrameworks["Flutter"] = "flutter";
20
+ FronteggFrameworks["Ios"] = "ios";
21
+ FronteggFrameworks["Android"] = "android";
22
+ FronteggFrameworks["Vanillajs"] = "vanillajs";
23
+ })(FronteggFrameworks || (FronteggFrameworks = {}));
24
+ export let PaginationOrderEnum;
25
+ (function (PaginationOrderEnum) {
26
+ PaginationOrderEnum["ASC"] = "ASC";
27
+ PaginationOrderEnum["DESC"] = "DESC";
28
+ })(PaginationOrderEnum || (PaginationOrderEnum = {}));
package/jwt.js CHANGED
@@ -1,76 +1,75 @@
1
+ /**
2
+ * The code was extracted from:
3
+ * https://github.com/davidchambers/Base64.js
4
+ */
5
+
1
6
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
2
7
  export class InvalidCharacterError extends Error {
3
8
  constructor(message) {
4
9
  super(message);
5
10
  }
6
-
7
11
  }
8
-
9
12
  function polyfill(input) {
10
13
  const str = String(input).replace(/=+$/, '');
11
-
12
14
  if (str.length % 4 === 1) {
13
15
  throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
14
16
  }
15
-
16
17
  let output = '';
17
-
18
- for (let bc = 0, bs, buffer, idx = 0; buffer = str.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
18
+ // noinspection JSAssignmentUsedAsCondition,JSUnusedAssignment,CommaExpressionJS
19
+ for (
20
+ // initialize result and counters
21
+ let bc = 0, bs, buffer, idx = 0;
22
+ // get next character
23
+ // tslint:disable-next-line:no-conditional-assignment
24
+ buffer = str.charAt(idx++);
25
+ // character found in table? initialize bit storage and add its ascii value;
26
+ // tslint:disable-next-line:no-conditional-assignment
27
+ ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
28
+ // and if not first of each 4 characters,
29
+ // convert the first 8 bits to one ascii character
30
+ bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
31
+ // try to find character in table (0-63, not found => -1)
19
32
  buffer = chars.indexOf(buffer);
20
33
  }
21
-
22
34
  return output;
23
35
  }
24
-
25
36
  const atob = typeof window !== 'undefined' && window.atob && window.atob.bind(window) || polyfill;
26
-
27
37
  function b64DecodeUnicode(str) {
28
38
  return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
29
39
  let code = p.charCodeAt(0).toString(16).toUpperCase();
30
-
31
40
  if (code.length < 2) {
32
41
  code = '0' + code;
33
42
  }
34
-
35
43
  return '%' + code;
36
44
  }));
37
45
  }
38
-
39
46
  const base64UrlDecode = str => {
40
47
  let output = str.replace(/-/g, '+').replace(/_/g, '/');
41
-
42
48
  switch (output.length % 4) {
43
49
  case 0:
44
50
  break;
45
-
46
51
  case 2:
47
52
  output += '==';
48
53
  break;
49
-
50
54
  case 3:
51
55
  output += '=';
52
56
  break;
53
-
54
57
  default:
55
58
  throw new Error('Illegal base64url string!');
56
59
  }
57
-
58
60
  try {
59
61
  return b64DecodeUnicode(output);
60
62
  } catch (err) {
61
63
  return atob(output);
62
64
  }
63
65
  };
64
-
65
66
  export class InvalidTokenError extends Error {
66
67
  constructor(message) {
67
68
  super(message);
68
69
  }
69
-
70
70
  }
71
71
  export const jwtDecode = (token, options = {}) => {
72
72
  const pos = !!options.header ? 0 : 1;
73
-
74
73
  try {
75
74
  return JSON.parse(base64UrlDecode(token.split('.')[pos]));
76
75
  } catch (e) {