@frontegg/rest-api 3.1.74-alpha.9436511986 → 3.1.74-alpha.9436935127
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.
- package/ContextHolder/index.d.ts +3 -2
- package/ContextHolder/index.js +3 -2
- package/FetchClient.d.ts +10 -3
- package/FetchClient.js +31 -9
- package/index.d.ts +7 -28
- package/index.js +2 -2
- package/node/ContextHolder/index.js +3 -2
- package/node/FetchClient.js +27 -12
- package/node/index.js +8 -1
- package/package.json +1 -1
package/ContextHolder/index.d.ts
CHANGED
|
@@ -112,12 +112,13 @@ export declare const FronteggContext: {
|
|
|
112
112
|
export declare const getFronteggContext: (appName?: string) => {
|
|
113
113
|
getContext: () => ContextOptions;
|
|
114
114
|
getAccessToken: () => string | null;
|
|
115
|
+
setAccessToken: (accessToken: string | null) => void;
|
|
115
116
|
getUser: () => IUserProfile | null;
|
|
117
|
+
setUser: (user: IUserProfile | null) => void;
|
|
116
118
|
onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void;
|
|
119
|
+
setOnRedirectTo: (onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void) => void;
|
|
117
120
|
logout: (callback?: (() => void) | undefined) => void;
|
|
118
121
|
getRequestSource: () => RequestSource | null;
|
|
119
|
-
setAccessToken: (accessToken: string | null) => void;
|
|
120
|
-
setUser: (user: IUserProfile | null) => void;
|
|
121
122
|
isSessionPerTenantEnabled: () => boolean;
|
|
122
123
|
shouldLoadEntitlements: () => boolean;
|
|
123
124
|
};
|
package/ContextHolder/index.js
CHANGED
|
@@ -123,12 +123,13 @@ export const FronteggContext = {
|
|
|
123
123
|
export const getFronteggContext = (appName = 'default') => ({
|
|
124
124
|
getContext: () => ContextHolder.getContext(appName),
|
|
125
125
|
getAccessToken: () => ContextHolder.getAccessToken(appName),
|
|
126
|
+
setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, appName),
|
|
126
127
|
getUser: () => ContextHolder.getUser(appName),
|
|
128
|
+
setUser: user => ContextHolder.setUser(user, appName),
|
|
127
129
|
onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts, appName),
|
|
130
|
+
setOnRedirectTo: onRedirectTo => ContextHolder.setOnRedirectTo(onRedirectTo, appName),
|
|
128
131
|
logout: callback => ContextHolder.logout(callback, appName),
|
|
129
132
|
getRequestSource: () => ContextHolder.getRequestSource(appName),
|
|
130
|
-
setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, appName),
|
|
131
|
-
setUser: user => ContextHolder.setUser(user, appName),
|
|
132
133
|
isSessionPerTenantEnabled: () => ContextHolder.isSessionPerTenantEnabled(appName),
|
|
133
134
|
shouldLoadEntitlements: () => ContextHolder.shouldLoadEntitlements(appName)
|
|
134
135
|
});
|
package/FetchClient.d.ts
CHANGED
|
@@ -22,10 +22,17 @@ export declare class FetchClient {
|
|
|
22
22
|
extractHeadersFromOptions: (options?: UserJwtOptions) => {
|
|
23
23
|
Authorization?: string;
|
|
24
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;
|
|
25
35
|
}
|
|
26
|
-
export declare function getBaseUrl(context: ContextOptions, url: string, withFronteggPrefix?: boolean): string;
|
|
27
|
-
export declare function getMetadataHeaders(context: ContextOptions): Record<string, string>;
|
|
28
|
-
export declare function getScopedTenant(): string | null;
|
|
29
36
|
declare const _default: FetchClient;
|
|
30
37
|
/**
|
|
31
38
|
* import FetchClient and use it to make requests to the server for specific application
|
package/FetchClient.js
CHANGED
|
@@ -13,7 +13,7 @@ export class FetchClient {
|
|
|
13
13
|
|
|
14
14
|
this.prepareUrl = async (url, params) => {
|
|
15
15
|
const context = this.getFronteggContext().getContext();
|
|
16
|
-
const baseUrl =
|
|
16
|
+
const baseUrl = this.getContextBaseUrl(url);
|
|
17
17
|
const paramsToSend = await this.buildQueryParams(context, params);
|
|
18
18
|
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
19
19
|
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
@@ -90,10 +90,10 @@ export class FetchClient {
|
|
|
90
90
|
|
|
91
91
|
const fronteggContext = this.getFronteggContext();
|
|
92
92
|
const context = fronteggContext.getContext();
|
|
93
|
-
const headers = getMetadataHeaders(context);
|
|
93
|
+
const headers = FetchClient.getMetadataHeaders(context);
|
|
94
94
|
const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : fronteggContext.getAccessToken)();
|
|
95
95
|
const requestSource = fronteggContext.getRequestSource();
|
|
96
|
-
const scopedTenant = getScopedTenant();
|
|
96
|
+
const scopedTenant = FetchClient.getScopedTenant();
|
|
97
97
|
|
|
98
98
|
if (contentType) {
|
|
99
99
|
headers[fronteggHeaders.contentType] = contentType;
|
|
@@ -232,11 +232,30 @@ export class FetchClient {
|
|
|
232
232
|
Authorization: options.jwt
|
|
233
233
|
} : {});
|
|
234
234
|
|
|
235
|
+
this.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
236
|
+
return FetchClient.getBaseUrl(context, url, withFronteggPrefix);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
this.getContextBaseUrl = (url, withFronteggPrefix = true) => {
|
|
240
|
+
const context = this.getFronteggContext().getContext();
|
|
241
|
+
return this.getBaseUrl(context, url, withFronteggPrefix);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
this.getMetadataHeaders = context => {
|
|
245
|
+
return FetchClient.getMetadataHeaders(context);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
this.getContextMetadataHeaders = () => {
|
|
249
|
+
const context = this.getFronteggContext().getContext();
|
|
250
|
+
return FetchClient.getMetadataHeaders(context);
|
|
251
|
+
};
|
|
252
|
+
|
|
235
253
|
this.appName = appName;
|
|
236
254
|
}
|
|
237
255
|
|
|
238
256
|
}
|
|
239
|
-
|
|
257
|
+
|
|
258
|
+
FetchClient.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
240
259
|
let baseUrl;
|
|
241
260
|
|
|
242
261
|
if (typeof context.baseUrl === 'function') {
|
|
@@ -257,8 +276,9 @@ export function getBaseUrl(context, url, withFronteggPrefix = true) {
|
|
|
257
276
|
}
|
|
258
277
|
|
|
259
278
|
return baseUrl;
|
|
260
|
-
}
|
|
261
|
-
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
FetchClient.getMetadataHeaders = context => {
|
|
262
282
|
var _context$metadataHead, _context$metadataHead2;
|
|
263
283
|
|
|
264
284
|
const headers = {};
|
|
@@ -272,8 +292,9 @@ export function getMetadataHeaders(context) {
|
|
|
272
292
|
}
|
|
273
293
|
|
|
274
294
|
return headers;
|
|
275
|
-
}
|
|
276
|
-
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
FetchClient.getScopedTenant = () => {
|
|
277
298
|
const urlParams = new URLSearchParams(window.location.search);
|
|
278
299
|
const scopedTenant = urlParams.get('tenantId');
|
|
279
300
|
|
|
@@ -282,5 +303,6 @@ export function getScopedTenant() {
|
|
|
282
303
|
}
|
|
283
304
|
|
|
284
305
|
return null;
|
|
285
|
-
}
|
|
306
|
+
};
|
|
307
|
+
|
|
286
308
|
export default new FetchClient('default');
|
package/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ declare const api: {
|
|
|
82
82
|
userPhoneNumbers: PhoneNumbersApi;
|
|
83
83
|
applications: ApplicationsApi;
|
|
84
84
|
};
|
|
85
|
-
declare
|
|
85
|
+
export declare type FronteggApiClient = {
|
|
86
86
|
auth: AuthenticationApi;
|
|
87
87
|
teams: TeamsApi;
|
|
88
88
|
metadata: MetadataApi;
|
|
@@ -106,7 +106,8 @@ declare const createApiClient: (appName: string) => {
|
|
|
106
106
|
userPhoneNumbers: PhoneNumbersApi;
|
|
107
107
|
applications: ApplicationsApi;
|
|
108
108
|
};
|
|
109
|
-
|
|
109
|
+
declare const createApiClient: (appName: string) => FronteggApiClient;
|
|
110
|
+
export { fetch, FetchClient, ContextHolder, FronteggContext, getFronteggContext, api, createApiClient, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy, };
|
|
110
111
|
declare const _default: {
|
|
111
112
|
fetch: FetchClient;
|
|
112
113
|
FetchClient: typeof FetchClient;
|
|
@@ -121,12 +122,13 @@ declare const _default: {
|
|
|
121
122
|
getFronteggContext: (appName?: string) => {
|
|
122
123
|
getContext: () => import("./interfaces").ContextOptions;
|
|
123
124
|
getAccessToken: () => string | null;
|
|
125
|
+
setAccessToken: (accessToken: string | null) => void;
|
|
124
126
|
getUser: () => import("./users/interfaces").IGetUsersV2Response | null;
|
|
127
|
+
setUser: (user: import("./users/interfaces").IGetUsersV2Response | null) => void;
|
|
125
128
|
onRedirectTo: (path: string, opts?: import("./interfaces").RedirectOptions | undefined) => void;
|
|
129
|
+
setOnRedirectTo: (onRedirectTo: (path: string, opts?: import("./interfaces").RedirectOptions | undefined) => void) => void;
|
|
126
130
|
logout: (callback?: (() => void) | undefined) => void;
|
|
127
131
|
getRequestSource: () => import("./interfaces").RequestSource | null;
|
|
128
|
-
setAccessToken: (accessToken: string | null) => void;
|
|
129
|
-
setUser: (user: import("./users/interfaces").IGetUsersV2Response | null) => void;
|
|
130
132
|
isSessionPerTenantEnabled: () => boolean;
|
|
131
133
|
shouldLoadEntitlements: () => boolean;
|
|
132
134
|
};
|
|
@@ -154,30 +156,7 @@ declare const _default: {
|
|
|
154
156
|
userPhoneNumbers: PhoneNumbersApi;
|
|
155
157
|
applications: ApplicationsApi;
|
|
156
158
|
};
|
|
157
|
-
createApiClient: (appName: string) =>
|
|
158
|
-
auth: AuthenticationApi;
|
|
159
|
-
teams: TeamsApi;
|
|
160
|
-
metadata: MetadataApi;
|
|
161
|
-
reports: ReportsApi;
|
|
162
|
-
connectivity: ConnectivityApi;
|
|
163
|
-
notifications: NotificationsApi;
|
|
164
|
-
audits: AuditsApi;
|
|
165
|
-
tenants: TenantsApi;
|
|
166
|
-
accountSettings: AccountSettingsApi;
|
|
167
|
-
roles: RolesApi;
|
|
168
|
-
subscriptions: SubscriptionsApi;
|
|
169
|
-
vendor: VendorApi;
|
|
170
|
-
subTenants: SubTenantsApi;
|
|
171
|
-
featureFlags: FeatureFlagsApi;
|
|
172
|
-
directory: DirectoryApi;
|
|
173
|
-
impersonate: ImpersonateApi;
|
|
174
|
-
groups: GroupsApi;
|
|
175
|
-
users: UsersApi;
|
|
176
|
-
entitlements: EntitlementsApi;
|
|
177
|
-
securityCenter: SecurityCenterApi;
|
|
178
|
-
userPhoneNumbers: PhoneNumbersApi;
|
|
179
|
-
applications: ApplicationsApi;
|
|
180
|
-
};
|
|
159
|
+
createApiClient: (appName: string) => FronteggApiClient;
|
|
181
160
|
FronteggApiError: typeof FronteggApiError;
|
|
182
161
|
AuthStrategyEnum: typeof AuthStrategyEnum;
|
|
183
162
|
MachineToMachineAuthStrategy: typeof MachineToMachineAuthStrategy;
|
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v3.1.74-alpha.
|
|
1
|
+
/** @license Frontegg v3.1.74-alpha.9436935127
|
|
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.
|
|
@@ -108,7 +108,7 @@ const createApiClient = appName => ({
|
|
|
108
108
|
applications: new ApplicationsApi(appName)
|
|
109
109
|
});
|
|
110
110
|
|
|
111
|
-
export { fetch, ContextHolder, FronteggContext, getFronteggContext, api, createApiClient, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy };
|
|
111
|
+
export { fetch, FetchClient, ContextHolder, FronteggContext, getFronteggContext, api, createApiClient, FronteggApiError, AuthStrategyEnum, SocialLoginProviders, ISubscriptionCancellationPolicy, ISubscriptionStatus, PaymentMethodType, ProviderType, MachineToMachineAuthStrategy };
|
|
112
112
|
export default {
|
|
113
113
|
fetch,
|
|
114
114
|
FetchClient,
|
|
@@ -134,12 +134,13 @@ exports.FronteggContext = FronteggContext;
|
|
|
134
134
|
const getFronteggContext = (appName = 'default') => ({
|
|
135
135
|
getContext: () => ContextHolder.getContext(appName),
|
|
136
136
|
getAccessToken: () => ContextHolder.getAccessToken(appName),
|
|
137
|
+
setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, appName),
|
|
137
138
|
getUser: () => ContextHolder.getUser(appName),
|
|
139
|
+
setUser: user => ContextHolder.setUser(user, appName),
|
|
138
140
|
onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts, appName),
|
|
141
|
+
setOnRedirectTo: onRedirectTo => ContextHolder.setOnRedirectTo(onRedirectTo, appName),
|
|
139
142
|
logout: callback => ContextHolder.logout(callback, appName),
|
|
140
143
|
getRequestSource: () => ContextHolder.getRequestSource(appName),
|
|
141
|
-
setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, appName),
|
|
142
|
-
setUser: user => ContextHolder.setUser(user, appName),
|
|
143
144
|
isSessionPerTenantEnabled: () => ContextHolder.isSessionPerTenantEnabled(appName),
|
|
144
145
|
shouldLoadEntitlements: () => ContextHolder.shouldLoadEntitlements(appName)
|
|
145
146
|
});
|
package/node/FetchClient.js
CHANGED
|
@@ -6,9 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.FetchClient = void 0;
|
|
9
|
-
exports.getBaseUrl = getBaseUrl;
|
|
10
|
-
exports.getMetadataHeaders = getMetadataHeaders;
|
|
11
|
-
exports.getScopedTenant = getScopedTenant;
|
|
12
9
|
|
|
13
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
11
|
|
|
@@ -30,7 +27,7 @@ class FetchClient {
|
|
|
30
27
|
|
|
31
28
|
this.prepareUrl = async (url, params) => {
|
|
32
29
|
const context = this.getFronteggContext().getContext();
|
|
33
|
-
const baseUrl =
|
|
30
|
+
const baseUrl = this.getContextBaseUrl(url);
|
|
34
31
|
const paramsToSend = await this.buildQueryParams(context, params);
|
|
35
32
|
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
36
33
|
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
@@ -107,10 +104,10 @@ class FetchClient {
|
|
|
107
104
|
|
|
108
105
|
const fronteggContext = this.getFronteggContext();
|
|
109
106
|
const context = fronteggContext.getContext();
|
|
110
|
-
const headers = getMetadataHeaders(context);
|
|
107
|
+
const headers = FetchClient.getMetadataHeaders(context);
|
|
111
108
|
const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : fronteggContext.getAccessToken)();
|
|
112
109
|
const requestSource = fronteggContext.getRequestSource();
|
|
113
|
-
const scopedTenant = getScopedTenant();
|
|
110
|
+
const scopedTenant = FetchClient.getScopedTenant();
|
|
114
111
|
|
|
115
112
|
if (contentType) {
|
|
116
113
|
headers[_interfaces.fronteggHeaders.contentType] = contentType;
|
|
@@ -249,6 +246,24 @@ class FetchClient {
|
|
|
249
246
|
Authorization: options.jwt
|
|
250
247
|
} : {});
|
|
251
248
|
|
|
249
|
+
this.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
250
|
+
return FetchClient.getBaseUrl(context, url, withFronteggPrefix);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
this.getContextBaseUrl = (url, withFronteggPrefix = true) => {
|
|
254
|
+
const context = this.getFronteggContext().getContext();
|
|
255
|
+
return this.getBaseUrl(context, url, withFronteggPrefix);
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
this.getMetadataHeaders = context => {
|
|
259
|
+
return FetchClient.getMetadataHeaders(context);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
this.getContextMetadataHeaders = () => {
|
|
263
|
+
const context = this.getFronteggContext().getContext();
|
|
264
|
+
return FetchClient.getMetadataHeaders(context);
|
|
265
|
+
};
|
|
266
|
+
|
|
252
267
|
this.appName = appName;
|
|
253
268
|
}
|
|
254
269
|
|
|
@@ -256,7 +271,7 @@ class FetchClient {
|
|
|
256
271
|
|
|
257
272
|
exports.FetchClient = FetchClient;
|
|
258
273
|
|
|
259
|
-
|
|
274
|
+
FetchClient.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
260
275
|
let baseUrl;
|
|
261
276
|
|
|
262
277
|
if (typeof context.baseUrl === 'function') {
|
|
@@ -277,9 +292,9 @@ function getBaseUrl(context, url, withFronteggPrefix = true) {
|
|
|
277
292
|
}
|
|
278
293
|
|
|
279
294
|
return baseUrl;
|
|
280
|
-
}
|
|
295
|
+
};
|
|
281
296
|
|
|
282
|
-
|
|
297
|
+
FetchClient.getMetadataHeaders = context => {
|
|
283
298
|
var _context$metadataHead, _context$metadataHead2;
|
|
284
299
|
|
|
285
300
|
const headers = {};
|
|
@@ -293,9 +308,9 @@ function getMetadataHeaders(context) {
|
|
|
293
308
|
}
|
|
294
309
|
|
|
295
310
|
return headers;
|
|
296
|
-
}
|
|
311
|
+
};
|
|
297
312
|
|
|
298
|
-
|
|
313
|
+
FetchClient.getScopedTenant = () => {
|
|
299
314
|
const urlParams = new URLSearchParams(window.location.search);
|
|
300
315
|
const scopedTenant = urlParams.get('tenantId');
|
|
301
316
|
|
|
@@ -304,7 +319,7 @@ function getScopedTenant() {
|
|
|
304
319
|
}
|
|
305
320
|
|
|
306
321
|
return null;
|
|
307
|
-
}
|
|
322
|
+
};
|
|
308
323
|
|
|
309
324
|
var _default = new FetchClient('default');
|
|
310
325
|
|
package/node/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license Frontegg v3.1.74-alpha.
|
|
1
|
+
/** @license Frontegg v3.1.74-alpha.9436935127
|
|
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.
|
|
@@ -25,6 +25,7 @@ var _exportNames = {
|
|
|
25
25
|
ProviderType: true,
|
|
26
26
|
FronteggApiError: true,
|
|
27
27
|
fetch: true,
|
|
28
|
+
FetchClient: true,
|
|
28
29
|
ContextHolder: true,
|
|
29
30
|
FronteggContext: true,
|
|
30
31
|
getFronteggContext: true
|
|
@@ -47,6 +48,12 @@ Object.defineProperty(exports, "FRONTEGG_SEPARATE_TABS_BY_TENANT", {
|
|
|
47
48
|
return _auth.FRONTEGG_SEPARATE_TABS_BY_TENANT;
|
|
48
49
|
}
|
|
49
50
|
});
|
|
51
|
+
Object.defineProperty(exports, "FetchClient", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _FetchClient.FetchClient;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
50
57
|
Object.defineProperty(exports, "FronteggApiError", {
|
|
51
58
|
enumerable: true,
|
|
52
59
|
get: function () {
|