@frontegg/js 7.0.0-alpha.0 → 7.0.0-alpha.2
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/AdminPortalRenderer/index.js +1 -2
- package/FronteggApp/FronteggApp.d.ts +36 -7
- package/FronteggApp/FronteggApp.js +125 -36
- package/FronteggApp/utils.d.ts +5 -0
- package/FronteggApp/utils.js +33 -0
- package/HostedLogin/index.js +6 -8
- package/LoginBoxRenderer/index.js +1 -2
- package/index.js +1 -1
- package/node/AdminPortalRenderer/index.js +1 -2
- package/node/FronteggApp/FronteggApp.js +123 -35
- package/node/FronteggApp/utils.js +39 -0
- package/node/HostedLogin/index.js +6 -8
- package/node/LoginBoxRenderer/index.js +1 -2
- package/node/index.js +1 -1
- package/node/utils/mockFlagsList.js +1 -1
- package/node/version.js +1 -1
- package/package.json +2 -2
- package/umd/frontegg-helpers.production.min.js +1 -1
- package/umd/frontegg.development.js +25923 -28361
- package/umd/frontegg.production.min.js +1 -1
- package/umd/frontegg.production.min.js.LICENSE.txt +25 -17
- package/utils/mockFlagsList.js +1 -1
- package/version.js +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -37,7 +36,7 @@ export var AdminPortalRenderer = /*#__PURE__*/function () {
|
|
|
37
36
|
appName: name
|
|
38
37
|
}, this, true, undefined, undefined, true);
|
|
39
38
|
}
|
|
40
|
-
this.options =
|
|
39
|
+
this.options = Object.assign({
|
|
41
40
|
themeOptions: themeOptions,
|
|
42
41
|
iframeRendering: true,
|
|
43
42
|
metadata: {},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FronteggStore, EntitledToOptions, Entitlement, StepUpOptions, IsSteppedUpOptions } from '@frontegg/redux-store';
|
|
2
2
|
import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides, LoadEntitlementsCallback } from '@frontegg/types';
|
|
3
3
|
import { IFeatureFlagsAttributes } from '@frontegg/rest-api';
|
|
4
|
+
import { CustomAttributes } from '@frontegg/entitlements-javascript-commons';
|
|
4
5
|
declare type FronteggAppContainers = {
|
|
5
6
|
adminPortalEl: HTMLElement;
|
|
6
7
|
loginBoxEl: HTMLElement;
|
|
@@ -25,7 +26,7 @@ export declare class FronteggApp {
|
|
|
25
26
|
loginBoxContainer?: HTMLElement;
|
|
26
27
|
checkoutDialogContainer?: HTMLElement;
|
|
27
28
|
loginBoxRenderer?: any;
|
|
28
|
-
store:
|
|
29
|
+
store: FronteggStore;
|
|
29
30
|
loadingListeners: (() => void)[];
|
|
30
31
|
updateLocalizations?: (localizations: LocalizationsOverrides) => void;
|
|
31
32
|
constructor(_options: FronteggAppOptions, name: string, iframeRendering?: boolean, allowMultipleRenderers?: boolean);
|
|
@@ -34,6 +35,7 @@ export declare class FronteggApp {
|
|
|
34
35
|
* @param entitlementsOptions - entitlements options from frontegg options
|
|
35
36
|
*/
|
|
36
37
|
private setEntitlementsOptions;
|
|
38
|
+
private setSessionContext;
|
|
37
39
|
loadAdminBoxMetadata: () => Promise<void>;
|
|
38
40
|
/**
|
|
39
41
|
* Loading required information on first load, mainly for refresh token and initial data.
|
|
@@ -48,6 +50,11 @@ export declare class FronteggApp {
|
|
|
48
50
|
* @param previewFeatureFlags
|
|
49
51
|
*/
|
|
50
52
|
setFeatureFlagsForPreview: (previewFeatureFlags: IFeatureFlagsAttributes) => void;
|
|
53
|
+
/**
|
|
54
|
+
* @param flags keys to check
|
|
55
|
+
* @returns an array of feature flags on/off boolean values
|
|
56
|
+
*/
|
|
57
|
+
private queryFeatureFlags;
|
|
51
58
|
initContainers(elements: FronteggAppContainers): Promise<void>;
|
|
52
59
|
updateLocalizationsSetter: (localizationUpdateFn: (localizations: LocalizationsOverrides) => void) => void;
|
|
53
60
|
updateMetadata(metadata: FronteggAppOptions['metadata']): void;
|
|
@@ -66,28 +73,50 @@ export declare class FronteggApp {
|
|
|
66
73
|
*/
|
|
67
74
|
private getEntitlementsFromStore;
|
|
68
75
|
/**
|
|
69
|
-
|
|
76
|
+
* @returns user store data
|
|
77
|
+
*/
|
|
78
|
+
private getUserFromStore;
|
|
79
|
+
/**
|
|
80
|
+
* @param customAttributes consumer attributes
|
|
81
|
+
* @returns is entitled query data including: entitltments state, final attributes (consumer and frontegg) and API version to use
|
|
82
|
+
*/
|
|
83
|
+
private getEntitlementsQueryData;
|
|
84
|
+
/**
|
|
85
|
+
@param key feature key
|
|
86
|
+
@param customAttributes user attributes
|
|
70
87
|
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
71
88
|
@throws when entitlement is not enabled via frontegg options
|
|
72
89
|
*/
|
|
73
|
-
getFeatureEntitlements(key: string): Entitlement;
|
|
90
|
+
getFeatureEntitlements(key: string, customAttributes?: CustomAttributes): Entitlement;
|
|
74
91
|
/**
|
|
75
|
-
@param key
|
|
92
|
+
@param key permission key
|
|
93
|
+
@param customAttributes user attributes
|
|
76
94
|
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
77
95
|
@throws when entitlement is not enabled via frontegg options
|
|
78
96
|
*/
|
|
79
|
-
getPermissionEntitlements(key: string): Entitlement;
|
|
97
|
+
getPermissionEntitlements(key: string, customAttributes?: CustomAttributes): Entitlement;
|
|
80
98
|
/**
|
|
81
99
|
@param options - including permission or feature key
|
|
100
|
+
@param customAttributes user attributes
|
|
82
101
|
@returns if the user is entitled to the given permission or feature. Attaching the justification if not
|
|
83
102
|
@throws when entitlement is not enabled via frontegg options
|
|
84
103
|
*/
|
|
85
|
-
getEntitlements(options: EntitledToOptions): Entitlement;
|
|
104
|
+
getEntitlements(options: EntitledToOptions, customAttributes?: CustomAttributes): Entitlement;
|
|
86
105
|
/**
|
|
87
106
|
* Load entitlements
|
|
88
107
|
* @param callback called on request completed with true if succeeded, false if failed
|
|
89
108
|
*/
|
|
90
109
|
loadEntitlements(callback?: LoadEntitlementsCallback): void;
|
|
110
|
+
/**
|
|
111
|
+
* Redirects to the step up page with the max age param and set the redirect url in the local storage
|
|
112
|
+
* @param options.maxAge optional max age
|
|
113
|
+
*/
|
|
114
|
+
stepUp(options?: StepUpOptions): void;
|
|
115
|
+
/**
|
|
116
|
+
* @param options.maxAge optional max age
|
|
117
|
+
* @return true when user is stepped up, false otherwise
|
|
118
|
+
*/
|
|
119
|
+
isSteppedUp(options?: IsSteppedUpOptions): boolean;
|
|
91
120
|
close(): void;
|
|
92
121
|
}
|
|
93
122
|
export {};
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
-
import {
|
|
6
|
+
import { getPermissionEntitlements as _getPermissionEntitlements, getFeatureEntitlements as _getFeatureEntitlements, redirectByStepUpUrl, isSteppedUp as _isSteppedUp, createStore } from '@frontegg/redux-store';
|
|
7
7
|
import { Metadata } from '@frontegg/types';
|
|
8
8
|
import { formatName, restoreSearchParams } from '../utils';
|
|
9
9
|
import { AppHolder } from '../AppHolder';
|
|
10
|
-
import { fetch as FronteggFetch, ContextHolder } from '@frontegg/rest-api';
|
|
10
|
+
import { fetch as FronteggFetch, ContextHolder, USE_ENTITLEMENTS_V2_ENDPOINT_FF } from '@frontegg/rest-api';
|
|
11
11
|
import { RequestSource } from '@frontegg/rest-api';
|
|
12
12
|
import * as FronteggRestApi from '@frontegg/rest-api';
|
|
13
13
|
import * as FronteggTypes from '@frontegg/types';
|
|
14
|
+
import * as FronteggReduxStore from '@frontegg/redux-store';
|
|
14
15
|
import versions from '../version';
|
|
15
16
|
import { mockFlagsList } from '../utils/mockFlagsList';
|
|
17
|
+
import { loadGTM } from './utils';
|
|
18
|
+
import * as ValtioVanilla from 'valtio/vanilla';
|
|
16
19
|
export var FronteggApp = /*#__PURE__*/function () {
|
|
17
20
|
function FronteggApp(_options, name) {
|
|
18
21
|
var _this = this,
|
|
19
|
-
_this$options$authOpt3
|
|
22
|
+
_this$options$authOpt3,
|
|
23
|
+
_options$authOptions;
|
|
20
24
|
var iframeRendering = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
21
25
|
var allowMultipleRenderers = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
22
26
|
_classCallCheck(this, FronteggApp);
|
|
@@ -78,14 +82,16 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
78
82
|
case 0:
|
|
79
83
|
shouldRequestHostedLoginAuthorize = (_this$options$authOpt = _this.options.authOptions) == null ? void 0 : (_this$options$authOpt2 = _this$options$authOpt.hostedLoginOptions) == null ? void 0 : _this$options$authOpt2.loadUserOnFirstLoad;
|
|
80
84
|
if (!_this.options.builderMode && _this.options.framework !== 'nextjs') {
|
|
81
|
-
if (_this.options.hostedLoginBox && !_this.options.customLoginBox
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
if (_this.options.hostedLoginBox && !_this.options.customLoginBox) {
|
|
86
|
+
if (shouldRequestHostedLoginAuthorize) {
|
|
87
|
+
_this.store.dispatch({
|
|
88
|
+
type: 'auth/requestHostedLoginAuthorizeV2',
|
|
89
|
+
payload: {
|
|
90
|
+
shouldRedirectToLogin: false,
|
|
91
|
+
firstTime: true
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
89
95
|
} else {
|
|
90
96
|
_this.store.dispatch({
|
|
91
97
|
type: 'auth/requestAuthorize',
|
|
@@ -134,7 +140,10 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
134
140
|
}, _callee3, null, [[4, 12]]);
|
|
135
141
|
}));
|
|
136
142
|
this.setFeatureFlagsForPreview = function (previewFeatureFlags) {
|
|
137
|
-
FronteggRestApi.FeatureFlags.set(
|
|
143
|
+
FronteggRestApi.FeatureFlags.set(Object.assign({}, mockFlagsList, previewFeatureFlags), _this.name);
|
|
144
|
+
};
|
|
145
|
+
this.queryFeatureFlags = function (flags) {
|
|
146
|
+
return FronteggRestApi.FeatureFlags.getFeatureFlags(flags, _this.name);
|
|
138
147
|
};
|
|
139
148
|
this.updateLocalizationsSetter = function (localizationUpdateFn) {
|
|
140
149
|
_this.updateLocalizations = localizationUpdateFn;
|
|
@@ -143,12 +152,31 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
143
152
|
var _this$store$getState$;
|
|
144
153
|
return (_this$store$getState$ = _this.store.getState().auth.user) == null ? void 0 : _this$store$getState$.entitlements;
|
|
145
154
|
};
|
|
155
|
+
this.getUserFromStore = function () {
|
|
156
|
+
return _this.store.getState().auth.user;
|
|
157
|
+
};
|
|
158
|
+
this.getEntitlementsQueryData = function (customAttributes) {
|
|
159
|
+
var user = _this.getUserFromStore();
|
|
160
|
+
var entitlements = _this.getEntitlementsFromStore();
|
|
161
|
+
var attributes = {
|
|
162
|
+
custom: customAttributes,
|
|
163
|
+
jwt: user
|
|
164
|
+
};
|
|
165
|
+
var _this$queryFeatureFla = _this.queryFeatureFlags([USE_ENTITLEMENTS_V2_ENDPOINT_FF]),
|
|
166
|
+
_this$queryFeatureFla2 = _slicedToArray(_this$queryFeatureFla, 1),
|
|
167
|
+
useEntitlementsV2 = _this$queryFeatureFla2[0];
|
|
168
|
+
return {
|
|
169
|
+
entitlements: entitlements,
|
|
170
|
+
attributes: attributes,
|
|
171
|
+
isV2: useEntitlementsV2
|
|
172
|
+
};
|
|
173
|
+
};
|
|
146
174
|
var appName = formatName(name);
|
|
147
175
|
var customElementName = "frontegg-app-".concat(appName);
|
|
148
176
|
this.iframeRendering = iframeRendering;
|
|
149
177
|
this.name = appName;
|
|
150
|
-
this.options =
|
|
151
|
-
contextOptions:
|
|
178
|
+
this.options = Object.assign({}, _options, {
|
|
179
|
+
contextOptions: Object.assign({
|
|
152
180
|
requestCredentials: 'include'
|
|
153
181
|
}, _options.contextOptions)
|
|
154
182
|
});
|
|
@@ -156,11 +184,12 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
156
184
|
this.cdnUrl = this.options.cdnUrl;
|
|
157
185
|
}
|
|
158
186
|
this.customElementName = customElementName;
|
|
159
|
-
var authOptions = this.options.authOptions ?
|
|
187
|
+
var authOptions = this.options.authOptions ? Object.assign({}, this.options.authOptions, {
|
|
160
188
|
hostedLoginBox: this.options.hostedLoginBox
|
|
161
189
|
}) : {
|
|
162
190
|
hostedLoginBox: this.options.hostedLoginBox
|
|
163
191
|
};
|
|
192
|
+
authOptions.onRedirectTo = _options.onRedirectTo;
|
|
164
193
|
authOptions.disableSilentRefresh = (_this$options$authOpt3 = this.options.authOptions) == null ? void 0 : _this$options$authOpt3.disableSilentRefresh;
|
|
165
194
|
if (this.options.store) {
|
|
166
195
|
this.store = this.options.store;
|
|
@@ -169,16 +198,24 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
169
198
|
}
|
|
170
199
|
} else {
|
|
171
200
|
var _this$options$authOpt4, _this$options$auditsO;
|
|
172
|
-
this.store =
|
|
201
|
+
this.store = createStore({
|
|
173
202
|
context: this.options.contextOptions,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
203
|
+
name: this.name,
|
|
204
|
+
builderMode: this.options.builderMode,
|
|
205
|
+
previewMode: this.options.previewMode,
|
|
206
|
+
storeHolder: this,
|
|
207
|
+
urlStrategy: this.options.urlStrategy,
|
|
208
|
+
initialState: {
|
|
209
|
+
auth: Object.assign({}, authOptions, (_this$options$authOpt4 = this.options.authOptions) != null ? _this$options$authOpt4 : {}),
|
|
210
|
+
auditLogs: Object.assign({}, (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {})
|
|
211
|
+
}
|
|
212
|
+
});
|
|
179
213
|
}
|
|
180
214
|
AppHolder.setInstance(appName, this);
|
|
181
215
|
this.setEntitlementsOptions(_options.entitlementsOptions);
|
|
216
|
+
this.setSessionContext({
|
|
217
|
+
enableSessionPerTenant: (_options$authOptions = _options.authOptions) == null ? void 0 : _options$authOptions.enableSessionPerTenant
|
|
218
|
+
});
|
|
182
219
|
|
|
183
220
|
// for feature flags (for entitlements)
|
|
184
221
|
ContextHolder.setAppName(appName);
|
|
@@ -191,7 +228,12 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
191
228
|
_createClass(FronteggApp, [{
|
|
192
229
|
key: "setEntitlementsOptions",
|
|
193
230
|
value: function setEntitlementsOptions(entitlementsOptions) {
|
|
194
|
-
ContextHolder.setEntitlementsOptions(
|
|
231
|
+
ContextHolder.setEntitlementsOptions(Object.assign({}, entitlementsOptions));
|
|
232
|
+
}
|
|
233
|
+
}, {
|
|
234
|
+
key: "setSessionContext",
|
|
235
|
+
value: function setSessionContext(sessionContext) {
|
|
236
|
+
ContextHolder.setSessionContext(Object.assign({}, sessionContext));
|
|
195
237
|
}
|
|
196
238
|
}, {
|
|
197
239
|
key: "initContainers",
|
|
@@ -223,6 +265,7 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
223
265
|
case 11:
|
|
224
266
|
if (!this.options.previewMode && !this.options.customLoginBox) {
|
|
225
267
|
this.loadLoginBox();
|
|
268
|
+
loadGTM(this.name);
|
|
226
269
|
}
|
|
227
270
|
if (!this.options.lazyLoadAdminPortal) {
|
|
228
271
|
this.loadScript('FronteggAdminPortal');
|
|
@@ -316,7 +359,9 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
316
359
|
if (window["".concat(component, "Init")]) {
|
|
317
360
|
resolve(window["".concat(component, "Init")]({
|
|
318
361
|
FronteggRestApi: FronteggRestApi,
|
|
319
|
-
FronteggTypes: FronteggTypes
|
|
362
|
+
FronteggTypes: FronteggTypes,
|
|
363
|
+
FronteggReduxStore: FronteggReduxStore,
|
|
364
|
+
ValtioVanilla: ValtioVanilla
|
|
320
365
|
}));
|
|
321
366
|
} else {
|
|
322
367
|
resolve(window[component]);
|
|
@@ -420,7 +465,7 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
420
465
|
return this.loadScript('FronteggAdminPortal');
|
|
421
466
|
case 2:
|
|
422
467
|
FronteggAdminPortal = _context7.sent;
|
|
423
|
-
this.checkoutDialogRenderer = FronteggAdminPortal.renderCheckoutDialog(this.checkoutDialogEl,
|
|
468
|
+
this.checkoutDialogRenderer = FronteggAdminPortal.renderCheckoutDialog(this.checkoutDialogEl, Object.assign({
|
|
424
469
|
injector: this
|
|
425
470
|
}, opts, {
|
|
426
471
|
options: this.options
|
|
@@ -454,40 +499,49 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
454
499
|
key: "getFeatureEntitlements",
|
|
455
500
|
value:
|
|
456
501
|
/**
|
|
457
|
-
@param key
|
|
502
|
+
@param key feature key
|
|
503
|
+
@param customAttributes user attributes
|
|
458
504
|
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
459
505
|
@throws when entitlement is not enabled via frontegg options
|
|
460
506
|
*/
|
|
461
|
-
function getFeatureEntitlements(key) {
|
|
462
|
-
var
|
|
463
|
-
|
|
507
|
+
function getFeatureEntitlements(key, customAttributes) {
|
|
508
|
+
var _this$getEntitlements = this.getEntitlementsQueryData(customAttributes),
|
|
509
|
+
entitlements = _this$getEntitlements.entitlements,
|
|
510
|
+
attributes = _this$getEntitlements.attributes,
|
|
511
|
+
isV2 = _this$getEntitlements.isV2;
|
|
512
|
+
return _getFeatureEntitlements(entitlements, key, attributes, isV2);
|
|
464
513
|
}
|
|
465
514
|
|
|
466
515
|
/**
|
|
467
|
-
@param key
|
|
516
|
+
@param key permission key
|
|
517
|
+
@param customAttributes user attributes
|
|
468
518
|
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
469
519
|
@throws when entitlement is not enabled via frontegg options
|
|
470
520
|
*/
|
|
471
521
|
}, {
|
|
472
522
|
key: "getPermissionEntitlements",
|
|
473
|
-
value: function getPermissionEntitlements(key) {
|
|
474
|
-
var
|
|
475
|
-
|
|
523
|
+
value: function getPermissionEntitlements(key, customAttributes) {
|
|
524
|
+
var _this$getEntitlements2 = this.getEntitlementsQueryData(customAttributes),
|
|
525
|
+
entitlements = _this$getEntitlements2.entitlements,
|
|
526
|
+
attributes = _this$getEntitlements2.attributes,
|
|
527
|
+
isV2 = _this$getEntitlements2.isV2;
|
|
528
|
+
return _getPermissionEntitlements(entitlements, key, attributes, isV2);
|
|
476
529
|
}
|
|
477
530
|
|
|
478
531
|
/**
|
|
479
532
|
@param options - including permission or feature key
|
|
533
|
+
@param customAttributes user attributes
|
|
480
534
|
@returns if the user is entitled to the given permission or feature. Attaching the justification if not
|
|
481
535
|
@throws when entitlement is not enabled via frontegg options
|
|
482
536
|
*/
|
|
483
537
|
}, {
|
|
484
538
|
key: "getEntitlements",
|
|
485
|
-
value: function getEntitlements(options) {
|
|
539
|
+
value: function getEntitlements(options, customAttributes) {
|
|
486
540
|
// we use permissionKey (options key) to decide if the user is using permission key or feature key
|
|
487
541
|
if ('permissionKey' in options) {
|
|
488
|
-
return this.getPermissionEntitlements(options.permissionKey);
|
|
542
|
+
return this.getPermissionEntitlements(options.permissionKey, customAttributes);
|
|
489
543
|
}
|
|
490
|
-
return this.getFeatureEntitlements(options.featureKey);
|
|
544
|
+
return this.getFeatureEntitlements(options.featureKey, customAttributes);
|
|
491
545
|
}
|
|
492
546
|
|
|
493
547
|
/**
|
|
@@ -504,6 +558,41 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
504
558
|
}
|
|
505
559
|
});
|
|
506
560
|
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Redirects to the step up page with the max age param and set the redirect url in the local storage
|
|
564
|
+
* @param options.maxAge optional max age
|
|
565
|
+
*/
|
|
566
|
+
}, {
|
|
567
|
+
key: "stepUp",
|
|
568
|
+
value: function stepUp(options) {
|
|
569
|
+
var state = this.store.getState();
|
|
570
|
+
var _ref4 = (state == null ? void 0 : state.auth) || {},
|
|
571
|
+
hostedLoginBox = _ref4.hostedLoginBox,
|
|
572
|
+
stepUpUrl = _ref4.routes.stepUpUrl;
|
|
573
|
+
if (hostedLoginBox) {
|
|
574
|
+
this.store.dispatch({
|
|
575
|
+
type: 'auth/stepUpHostedLogin',
|
|
576
|
+
payload: options
|
|
577
|
+
});
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
redirectByStepUpUrl(stepUpUrl, state.auth.onRedirectTo, options == null ? void 0 : options.maxAge);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @param options.maxAge optional max age
|
|
585
|
+
* @return true when user is stepped up, false otherwise
|
|
586
|
+
*/
|
|
587
|
+
}, {
|
|
588
|
+
key: "isSteppedUp",
|
|
589
|
+
value: function isSteppedUp() {
|
|
590
|
+
var _this$store$getState;
|
|
591
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
592
|
+
var _ref5 = ((_this$store$getState = this.store.getState()) == null ? void 0 : _this$store$getState.auth) || {},
|
|
593
|
+
user = _ref5.user;
|
|
594
|
+
return _isSteppedUp(user, options);
|
|
595
|
+
}
|
|
507
596
|
}, {
|
|
508
597
|
key: "close",
|
|
509
598
|
value: function close() {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Metadata } from '@frontegg/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* To prevent XSS attack, this function check for gtm key validity
|
|
5
|
+
* XSS attack may happen if values are injected by postman because we don't have validity check in the BE
|
|
6
|
+
*
|
|
7
|
+
* @param key gtm key
|
|
8
|
+
* @returns true if gtm key is valid: starts with GTM- and contains letters and digits only
|
|
9
|
+
*/
|
|
10
|
+
var isValidGTMKey = function isValidGTMKey(key) {
|
|
11
|
+
return /^GTM-[a-zA-Z0-9]+$/.test(key);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* load gtm scripts by using metadata gtm keys
|
|
16
|
+
* @param fronteggAppName
|
|
17
|
+
*/
|
|
18
|
+
export var loadGTM = function loadGTM(fronteggAppName) {
|
|
19
|
+
var _metadata$integration;
|
|
20
|
+
var metadata = Metadata.getInstance(fronteggAppName);
|
|
21
|
+
var gtmKeysConfig = metadata == null ? void 0 : (_metadata$integration = metadata.integrations) == null ? void 0 : _metadata$integration.gtm;
|
|
22
|
+
gtmKeysConfig == null ? void 0 : gtmKeysConfig.filter(function (_ref) {
|
|
23
|
+
var id = _ref.id,
|
|
24
|
+
enabled = _ref.enabled;
|
|
25
|
+
return enabled && isValidGTMKey(id);
|
|
26
|
+
}).forEach(function (_ref2) {
|
|
27
|
+
var id = _ref2.id;
|
|
28
|
+
// Load GTM container script dynamically
|
|
29
|
+
var script = document.createElement('script');
|
|
30
|
+
script.innerHTML = "\n (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','".concat(id, "');\n ");
|
|
31
|
+
document.body.appendChild(script);
|
|
32
|
+
});
|
|
33
|
+
};
|
package/HostedLogin/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import { authActions } from '@frontegg/redux-store';
|
|
5
3
|
import { AppHolder } from '../AppHolder';
|
|
6
4
|
import { ContextHolder } from '@frontegg/rest-api';
|
|
7
5
|
export var HostedLogin = /*#__PURE__*/function () {
|
|
@@ -15,23 +13,23 @@ export var HostedLogin = /*#__PURE__*/function () {
|
|
|
15
13
|
var app = AppHolder.getInstance(appName);
|
|
16
14
|
if (isAuthenticated && accessToken) {
|
|
17
15
|
ContextHolder.setAccessToken(accessToken);
|
|
18
|
-
ContextHolder.setUser(
|
|
16
|
+
ContextHolder.setUser(Object.assign({}, user, {
|
|
19
17
|
accessToken: accessToken
|
|
20
18
|
}));
|
|
21
|
-
app.store.
|
|
19
|
+
app.store.actions.setAuthState({
|
|
22
20
|
isLoading: false,
|
|
23
21
|
isAuthenticated: isAuthenticated,
|
|
24
22
|
user: user
|
|
25
|
-
})
|
|
26
|
-
app.store.
|
|
23
|
+
});
|
|
24
|
+
app.store.actions.loadTenants();
|
|
27
25
|
} else {
|
|
28
26
|
ContextHolder.setAccessToken(null);
|
|
29
27
|
ContextHolder.setUser(null);
|
|
30
|
-
app.store.
|
|
28
|
+
app.store.actions.setAuthState({
|
|
31
29
|
isLoading: false,
|
|
32
30
|
isAuthenticated: false,
|
|
33
31
|
user: null
|
|
34
|
-
})
|
|
32
|
+
});
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
}]);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -39,7 +38,7 @@ export var LoginBoxRenderer = /*#__PURE__*/function () {
|
|
|
39
38
|
appName: name
|
|
40
39
|
}, this, true, undefined, undefined, true);
|
|
41
40
|
}
|
|
42
|
-
this.options =
|
|
41
|
+
this.options = Object.assign({
|
|
43
42
|
themeOptions: themeOptions,
|
|
44
43
|
iframeRendering: true,
|
|
45
44
|
metadata: {},
|
package/index.js
CHANGED
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getThemeAdminByName = exports["default"] = exports.AdminPortalRenderer = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
12
|
var _reduxStore = require("@frontegg/redux-store");
|
|
@@ -45,7 +44,7 @@ var AdminPortalRenderer = /*#__PURE__*/function () {
|
|
|
45
44
|
appName: name
|
|
46
45
|
}, this, true, undefined, undefined, true);
|
|
47
46
|
}
|
|
48
|
-
this.options = (
|
|
47
|
+
this.options = Object.assign({
|
|
49
48
|
themeOptions: themeOptions,
|
|
50
49
|
iframeRendering: true,
|
|
51
50
|
metadata: {},
|