@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.
- package/BaseApiClient.d.ts +16 -0
- package/BaseApiClient.js +39 -0
- package/ContextHolder/index.d.ts +81 -24
- package/ContextHolder/index.js +55 -43
- package/FetchClient.d.ts +35 -0
- package/FetchClient.js +286 -0
- package/account-settings/index.d.ts +19 -7
- package/account-settings/index.js +23 -13
- package/applications/index.d.ts +49 -44
- package/applications/index.js +51 -37
- package/audits/index.d.ts +27 -15
- package/audits/index.js +27 -17
- package/auth/index.d.ts +764 -768
- package/auth/index.js +875 -721
- package/auth/secutiry-poilicy/index.d.ts +58 -102
- package/auth/secutiry-poilicy/index.js +122 -90
- package/auth/utils.d.ts +2 -2
- package/auth/utils.js +10 -9
- package/connectivity/index.d.ts +125 -26
- package/connectivity/index.js +147 -114
- package/directory/index.d.ts +31 -22
- package/directory/index.js +27 -15
- package/entitlements/index.d.ts +14 -8
- package/entitlements/index.js +12 -4
- package/feature-flags/index.d.ts +8 -2
- package/feature-flags/index.js +16 -8
- package/groups/index.d.ts +73 -49
- package/groups/index.js +64 -45
- package/impersonate/index.d.ts +15 -6
- package/impersonate/index.js +13 -5
- package/index.d.ts +174 -108
- package/index.js +108 -79
- package/interfaces.d.ts +10 -0
- package/metadata/index.d.ts +67 -7
- package/metadata/index.js +52 -32
- package/node/BaseApiClient.js +49 -0
- package/node/ContextHolder/index.js +59 -44
- package/node/FetchClient.js +311 -0
- package/node/account-settings/index.js +27 -16
- package/node/applications/index.js +51 -44
- package/node/audits/index.js +31 -20
- package/node/auth/index.js +746 -1036
- package/node/auth/secutiry-poilicy/index.js +125 -136
- package/node/auth/utils.js +9 -7
- package/node/connectivity/index.js +148 -187
- package/node/directory/index.js +29 -20
- package/node/entitlements/index.js +18 -5
- package/node/feature-flags/index.js +21 -9
- package/node/groups/index.js +65 -63
- package/node/impersonate/index.js +18 -5
- package/node/index.js +127 -71
- package/node/metadata/index.js +61 -52
- package/node/notifications/index.js +37 -27
- package/node/reports/index.js +78 -70
- package/node/roles/index.js +56 -51
- package/node/security-center/index.js +21 -9
- package/node/sub-tenants/index.js +83 -73
- package/node/sub-tenants/interfaces.js +10 -1
- package/node/subscriptions/index.js +79 -107
- package/node/subscriptions/invoices.js +25 -17
- package/node/subscriptions/managedSubscriptions.js +32 -27
- package/node/subscriptions/paymentMethods.js +27 -20
- package/node/subscriptions/paymentProviders.js +15 -6
- package/node/subscriptions/plans.js +17 -9
- package/node/subscriptions/providers/stripe/index.js +26 -21
- package/node/subscriptions/subscriptions.js +32 -27
- package/node/subscriptions/summaries.js +15 -6
- package/node/subscriptions/tenantConfiguration.js +17 -9
- package/node/subscriptions/vendorPublicConfigurations.js +15 -6
- package/node/teams/index.js +130 -138
- package/node/tenants/index.js +65 -60
- package/node/user-phone-numbers/index.js +32 -24
- package/node/users/index.js +58 -53
- package/node/vendor/index.js +17 -6
- package/notifications/index.d.ts +22 -16
- package/notifications/index.js +33 -22
- package/package.json +1 -1
- package/reports/index.d.ts +50 -44
- package/reports/index.js +75 -62
- package/roles/index.d.ts +44 -38
- package/roles/index.js +57 -41
- package/security-center/index.d.ts +14 -2
- package/security-center/index.js +15 -6
- package/sub-tenants/index.d.ts +57 -14
- package/sub-tenants/index.js +88 -61
- package/sub-tenants/interfaces.d.ts +8 -0
- package/sub-tenants/interfaces.js +7 -1
- package/subscriptions/index.d.ts +56 -11
- package/subscriptions/index.js +68 -11
- package/subscriptions/invoices.d.ts +16 -13
- package/subscriptions/invoices.js +24 -14
- package/subscriptions/managedSubscriptions.d.ts +18 -15
- package/subscriptions/managedSubscriptions.js +33 -22
- package/subscriptions/paymentMethods.d.ts +16 -13
- package/subscriptions/paymentMethods.js +26 -17
- package/subscriptions/paymentProviders.d.ts +8 -5
- package/subscriptions/paymentProviders.js +11 -4
- package/subscriptions/plans.d.ts +11 -8
- package/subscriptions/plans.js +14 -6
- package/subscriptions/providers/stripe/index.d.ts +24 -21
- package/subscriptions/providers/stripe/index.js +27 -16
- package/subscriptions/subscriptions.d.ts +24 -21
- package/subscriptions/subscriptions.js +33 -22
- package/subscriptions/summaries.d.ts +7 -4
- package/subscriptions/summaries.js +10 -3
- package/subscriptions/tenantConfiguration.d.ts +6 -3
- package/subscriptions/tenantConfiguration.js +15 -7
- package/subscriptions/vendorPublicConfigurations.d.ts +5 -2
- package/subscriptions/vendorPublicConfigurations.js +11 -4
- package/teams/index.d.ts +35 -131
- package/teams/index.js +122 -93
- package/tenants/index.d.ts +25 -37
- package/tenants/index.js +63 -47
- package/user-phone-numbers/index.d.ts +32 -26
- package/user-phone-numbers/index.js +32 -19
- package/users/index.d.ts +21 -15
- package/users/index.js +60 -44
- package/vendor/index.d.ts +12 -6
- package/vendor/index.js +11 -4
- package/fetch.d.ts +0 -24
- package/fetch.js +0 -265
- package/node/fetch.js +0 -306
- package/node/subscriptions/providers/index.js +0 -18
- package/subscriptions/providers/index.d.ts +0 -1
- 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
|
+
}
|
package/BaseApiClient.js
ADDED
|
@@ -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
|
+
}
|
package/ContextHolder/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SessionContext, ContextOptions, RedirectOptions, RequestSource } from '../interfaces';
|
|
2
|
-
import { IUserProfile } from
|
|
2
|
+
import { IUserProfile } from '../users/interfaces';
|
|
3
3
|
/**
|
|
4
4
|
* Entitlements config from frontegg provider
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@ export interface EntitlementsOptions {
|
|
|
7
7
|
enabled?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare class ContextHolder {
|
|
10
|
-
private static
|
|
10
|
+
private static _apps;
|
|
11
11
|
private context;
|
|
12
12
|
private accessToken;
|
|
13
13
|
private user;
|
|
@@ -18,45 +18,90 @@ export declare class ContextHolder {
|
|
|
18
18
|
private appName;
|
|
19
19
|
private sessionContext?;
|
|
20
20
|
private constructor();
|
|
21
|
-
static getInstance(): ContextHolder;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
static
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
static getInstance(appName?: string): ContextHolder;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated - use getFronteggContext(appName).setContext instead
|
|
24
|
+
*/
|
|
25
|
+
static setContext(context: ContextOptions, appName?: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated - use getFronteggContext(appName).setAccessToken instead
|
|
28
|
+
*/
|
|
29
|
+
static setAccessToken(accessToken: string | null, appName?: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated - use getFronteggContext(appName).setUser instead
|
|
32
|
+
*/
|
|
33
|
+
static setUser(user: IUserProfile | null, appName?: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated - use getFronteggContext(appName).setRequestSource instead
|
|
36
|
+
*/
|
|
37
|
+
static setRequestSource(requestSource: RequestSource | null, appName?: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated - use getFronteggContext(appName).setOnRedirectTo instead
|
|
40
|
+
*/
|
|
41
|
+
static setOnRedirectTo(onRedirectTo: (path: string, opts?: RedirectOptions) => void, appName?: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated - use getFronteggContext(appName).setLogout instead
|
|
44
|
+
*/
|
|
45
|
+
static setLogout(logout: (callback?: () => void) => void, logoutUrl: string, appName?: string): void;
|
|
28
46
|
/**
|
|
29
47
|
* App name should also be set for entitlements
|
|
48
|
+
* @deprecated - use getFronteggContext(appName).setEntitlementsOptions instead
|
|
30
49
|
* @param entitlementsOptions frontegg options entitlements config
|
|
50
|
+
* @param appName - app name
|
|
31
51
|
*/
|
|
32
|
-
static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions): void;
|
|
52
|
+
static setEntitlementsOptions(entitlementsOptions: EntitlementsOptions, appName?: string): void;
|
|
33
53
|
/**
|
|
54
|
+
* @deprecated - use getFronteggContext(appName).setSessionContext instead
|
|
34
55
|
* @param sessionContext frontegg options SessionContext config
|
|
56
|
+
* @param appName - app name
|
|
57
|
+
*/
|
|
58
|
+
static setSessionContext(sessionContext: SessionContext, appName?: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated - use getFronteggContext(appName).setAppName instead
|
|
61
|
+
*/
|
|
62
|
+
static setAppName(appName: string): void;
|
|
63
|
+
static getContext(appName?: string): ContextOptions;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated - use getFronteggContext(appName) instead
|
|
66
|
+
*/
|
|
67
|
+
static getAccessToken(appName?: string): string | null;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated - use getFronteggContext(appName).requestSource instead
|
|
70
|
+
*/
|
|
71
|
+
static getRequestSource(appName?: string): RequestSource | null;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated - use getFronteggContext(appName).getUser instead
|
|
74
|
+
*/
|
|
75
|
+
static getUser(appName?: string): IUserProfile | null;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated - use getFronteggContext(appName).onRedirectTo instead
|
|
35
78
|
*/
|
|
36
|
-
static
|
|
79
|
+
static onRedirectTo(path: string, opts?: RedirectOptions, appName?: string): void;
|
|
37
80
|
/**
|
|
38
|
-
* @
|
|
81
|
+
* @deprecated - use getFronteggContext(appName)/logout instead
|
|
39
82
|
*/
|
|
40
|
-
static
|
|
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;
|
|
83
|
+
static logout(callback?: () => void, appName?: string): void;
|
|
47
84
|
/**
|
|
85
|
+
* @deprecated - use getFronteggContext(appName).shouldLoadEntitlements instead
|
|
48
86
|
* @returns shouldLoadEntitlements. Default to false.
|
|
49
87
|
*/
|
|
50
|
-
static shouldLoadEntitlements(): boolean;
|
|
88
|
+
static shouldLoadEntitlements(appName?: string): boolean;
|
|
51
89
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
90
|
+
* @deprecated - use getFronteggContext(appName).isSessionPerTenantEnabled instead
|
|
91
|
+
* @returns isSessionPerTenantEnabled. Default to false.
|
|
92
|
+
*/
|
|
93
|
+
static isSessionPerTenantEnabled(appName?: string): boolean;
|
|
55
94
|
/**
|
|
95
|
+
* @deprecated - use getFronteggContext(appName).getAppName instead
|
|
56
96
|
* @returns app name value
|
|
57
97
|
*/
|
|
58
|
-
static getAppName(): string | null;
|
|
98
|
+
static getAppName(appName?: string): string | null;
|
|
59
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Frontegg context to be used in the application
|
|
102
|
+
*
|
|
103
|
+
* @deprecated use getFronteggContext instead
|
|
104
|
+
*/
|
|
60
105
|
export declare const FronteggContext: {
|
|
61
106
|
getContext: () => ContextOptions;
|
|
62
107
|
getAccessToken: () => string | null;
|
|
@@ -64,3 +109,15 @@ export declare const FronteggContext: {
|
|
|
64
109
|
onRedirectTo: (path: string, opts: RedirectOptions) => void;
|
|
65
110
|
logout: (callback?: (() => void) | undefined) => void;
|
|
66
111
|
};
|
|
112
|
+
export declare const getFronteggContext: (appName?: string) => {
|
|
113
|
+
getContext: () => ContextOptions;
|
|
114
|
+
getAccessToken: () => string | null;
|
|
115
|
+
getUser: () => IUserProfile | null;
|
|
116
|
+
onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void;
|
|
117
|
+
logout: (callback?: (() => void) | undefined) => void;
|
|
118
|
+
getRequestSource: () => RequestSource | null;
|
|
119
|
+
setAccessToken: (accessToken: string | null) => void;
|
|
120
|
+
setUser: (user: IUserProfile | null) => void;
|
|
121
|
+
isSessionPerTenantEnabled: () => boolean;
|
|
122
|
+
shouldLoadEntitlements: () => boolean;
|
|
123
|
+
};
|
package/ContextHolder/index.js
CHANGED
|
@@ -14,109 +14,121 @@ export class ContextHolder {
|
|
|
14
14
|
this.sessionContext = void 0;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
static getInstance() {
|
|
18
|
-
if (
|
|
19
|
-
ContextHolder.
|
|
17
|
+
static getInstance(appName = 'default') {
|
|
18
|
+
if (ContextHolder._apps[appName]) {
|
|
19
|
+
return ContextHolder._apps[appName];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
ContextHolder._apps[appName] = new ContextHolder();
|
|
23
|
+
return ContextHolder._apps[appName];
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
static setContext(context) {
|
|
26
|
-
ContextHolder.getInstance().context = context;
|
|
26
|
+
static setContext(context, appName = 'default') {
|
|
27
|
+
ContextHolder.getInstance(appName).context = context;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
static setAccessToken(accessToken) {
|
|
30
|
-
ContextHolder.getInstance().accessToken = accessToken;
|
|
30
|
+
static setAccessToken(accessToken, appName = 'default') {
|
|
31
|
+
ContextHolder.getInstance(appName).accessToken = accessToken;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
static setUser(user) {
|
|
34
|
-
ContextHolder.getInstance().user = user;
|
|
34
|
+
static setUser(user, appName = 'default') {
|
|
35
|
+
ContextHolder.getInstance(appName).user = user;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
static setRequestSource(requestSource) {
|
|
38
|
-
ContextHolder.getInstance().requestSource = requestSource;
|
|
38
|
+
static setRequestSource(requestSource, appName = 'default') {
|
|
39
|
+
ContextHolder.getInstance(appName).requestSource = requestSource;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
static setOnRedirectTo(onRedirectTo) {
|
|
42
|
-
ContextHolder.getInstance().onRedirectTo = onRedirectTo;
|
|
42
|
+
static setOnRedirectTo(onRedirectTo, appName = 'default') {
|
|
43
|
+
ContextHolder.getInstance(appName).onRedirectTo = onRedirectTo;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
static setLogout(logout, logoutUrl) {
|
|
46
|
-
ContextHolder.getInstance().logout = callback => {
|
|
46
|
+
static setLogout(logout, logoutUrl, appName = 'default') {
|
|
47
|
+
ContextHolder.getInstance(appName).logout = callback => {
|
|
47
48
|
if (!callback) {
|
|
48
|
-
ContextHolder.onRedirectTo(logoutUrl);
|
|
49
|
+
ContextHolder.onRedirectTo(logoutUrl, undefined, appName);
|
|
49
50
|
} else {
|
|
50
51
|
logout(callback);
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
static setEntitlementsOptions(entitlementsOptions) {
|
|
56
|
-
ContextHolder.getInstance().entitlementsOptions = entitlementsOptions;
|
|
56
|
+
static setEntitlementsOptions(entitlementsOptions, appName = 'default') {
|
|
57
|
+
ContextHolder.getInstance(appName).entitlementsOptions = entitlementsOptions;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
static setSessionContext(sessionContext) {
|
|
60
|
-
|
|
61
|
-
instance.sessionContext = sessionContext;
|
|
60
|
+
static setSessionContext(sessionContext, appName = 'default') {
|
|
61
|
+
ContextHolder.getInstance(appName).sessionContext = sessionContext;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
static setAppName(appName) {
|
|
65
|
-
ContextHolder.getInstance().appName = appName;
|
|
65
|
+
ContextHolder.getInstance(appName).appName = appName;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
static getContext() {
|
|
68
|
+
static getContext(appName = 'default') {
|
|
69
69
|
var _ContextHolder$getIns;
|
|
70
70
|
|
|
71
|
-
return (_ContextHolder$getIns = ContextHolder.getInstance().context) != null ? _ContextHolder$getIns : {
|
|
71
|
+
return (_ContextHolder$getIns = ContextHolder.getInstance(appName).context) != null ? _ContextHolder$getIns : {
|
|
72
72
|
baseUrl: window.location.href,
|
|
73
73
|
tokenResolver: () => 'my-authentication-token',
|
|
74
74
|
logLevel: 'error'
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
static getAccessToken() {
|
|
79
|
-
return ContextHolder.getInstance().accessToken;
|
|
78
|
+
static getAccessToken(appName = 'default') {
|
|
79
|
+
return ContextHolder.getInstance(appName).accessToken;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
static getRequestSource() {
|
|
83
|
-
return ContextHolder.getInstance().requestSource;
|
|
82
|
+
static getRequestSource(appName = 'default') {
|
|
83
|
+
return ContextHolder.getInstance(appName).requestSource;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
static getUser() {
|
|
87
|
-
return ContextHolder.getInstance().user;
|
|
86
|
+
static getUser(appName = 'default') {
|
|
87
|
+
return ContextHolder.getInstance(appName).user;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
static onRedirectTo(path, opts) {
|
|
91
|
-
return ContextHolder.getInstance().onRedirectTo(path, opts);
|
|
90
|
+
static onRedirectTo(path, opts, appName = 'default') {
|
|
91
|
+
return ContextHolder.getInstance(appName).onRedirectTo(path, opts);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
static logout(callback) {
|
|
95
|
-
return ContextHolder.getInstance().logout(callback);
|
|
94
|
+
static logout(callback, appName = 'default') {
|
|
95
|
+
return ContextHolder.getInstance(appName).logout(callback);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
static shouldLoadEntitlements() {
|
|
98
|
+
static shouldLoadEntitlements(appName = 'default') {
|
|
99
99
|
var _ContextHolder$getIns2;
|
|
100
100
|
|
|
101
|
-
return ((_ContextHolder$getIns2 = ContextHolder.getInstance().entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
|
|
101
|
+
return ((_ContextHolder$getIns2 = ContextHolder.getInstance(appName).entitlementsOptions) == null ? void 0 : _ContextHolder$getIns2.enabled) || false;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
static isSessionPerTenantEnabled() {
|
|
104
|
+
static isSessionPerTenantEnabled(appName = 'default') {
|
|
105
105
|
var _ContextHolder$getIns3;
|
|
106
106
|
|
|
107
|
-
return ((_ContextHolder$getIns3 = ContextHolder.getInstance().sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
|
|
107
|
+
return ((_ContextHolder$getIns3 = ContextHolder.getInstance(appName).sessionContext) == null ? void 0 : _ContextHolder$getIns3.enableSessionPerTenant) || false;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
static getAppName() {
|
|
111
|
-
return ContextHolder.getInstance().appName;
|
|
110
|
+
static getAppName(appName = 'default') {
|
|
111
|
+
return ContextHolder.getInstance(appName).appName;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
}
|
|
115
|
-
ContextHolder.
|
|
115
|
+
ContextHolder._apps = void 0;
|
|
116
116
|
export const FronteggContext = {
|
|
117
117
|
getContext: () => ContextHolder.getContext(),
|
|
118
118
|
getAccessToken: () => ContextHolder.getAccessToken(),
|
|
119
119
|
getUser: () => ContextHolder.getUser(),
|
|
120
120
|
onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts),
|
|
121
121
|
logout: callback => ContextHolder.logout(callback)
|
|
122
|
-
};
|
|
122
|
+
};
|
|
123
|
+
export const getFronteggContext = (appName = 'default') => ({
|
|
124
|
+
getContext: () => ContextHolder.getContext(appName),
|
|
125
|
+
getAccessToken: () => ContextHolder.getAccessToken(appName),
|
|
126
|
+
getUser: () => ContextHolder.getUser(appName),
|
|
127
|
+
onRedirectTo: (path, opts) => ContextHolder.onRedirectTo(path, opts, appName),
|
|
128
|
+
logout: callback => ContextHolder.logout(callback, appName),
|
|
129
|
+
getRequestSource: () => ContextHolder.getRequestSource(appName),
|
|
130
|
+
setAccessToken: accessToken => ContextHolder.setAccessToken(accessToken, appName),
|
|
131
|
+
setUser: user => ContextHolder.setUser(user, appName),
|
|
132
|
+
isSessionPerTenantEnabled: () => ContextHolder.isSessionPerTenantEnabled(appName),
|
|
133
|
+
shouldLoadEntitlements: () => ContextHolder.shouldLoadEntitlements(appName)
|
|
134
|
+
});
|
package/FetchClient.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
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
|
+
declare const _default: FetchClient;
|
|
30
|
+
/**
|
|
31
|
+
* import FetchClient and use it to make requests to the server for specific application
|
|
32
|
+
* @param appName - the application name to make requests for
|
|
33
|
+
* @deprecated - use FetchClient directly
|
|
34
|
+
*/
|
|
35
|
+
export default _default;
|