@frontegg/js 6.122.0 → 6.123.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.
@@ -28,6 +28,11 @@ export declare class FronteggApp {
28
28
  loadingListeners: (() => void)[];
29
29
  updateLocalizations?: (localizations: LocalizationsOverrides) => void;
30
30
  constructor(_options: FronteggAppOptions, name: string, iframeRendering?: boolean, allowMultipleRenderers?: boolean);
31
+ /**
32
+ * Set entitlements related options in context holder according to frontegg options
33
+ * @param fronteggAppOptions
34
+ */
35
+ private setEntitlementsOptions;
31
36
  loadAdminBoxMetadata: () => Promise<void>;
32
37
  requestAuthorize: () => Promise<void>;
33
38
  loadFeatureFlags: () => Promise<void>;
@@ -7,7 +7,7 @@ import { createFronteggStore, getPermissionEntitlements as _getPermissionEntitle
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 } from '@frontegg/rest-api';
10
+ import { fetch as FronteggFetch, ContextHolder } 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';
@@ -124,7 +124,8 @@ export var FronteggApp = /*#__PURE__*/function () {
124
124
  _this.updateLocalizations = localizationUpdateFn;
125
125
  };
126
126
  this.getEntitlementsFromStore = function () {
127
- return _this.store.getState().auth.entitlementsState;
127
+ var _this$store$getState$;
128
+ return (_this$store$getState$ = _this.store.getState().auth.user) == null ? void 0 : _this$store$getState$.entitlements;
128
129
  };
129
130
  var appName = formatName(name);
130
131
  var customElementName = "frontegg-app-".concat(appName);
@@ -151,19 +152,32 @@ export var FronteggApp = /*#__PURE__*/function () {
151
152
  throw Error('Mismatch in store names');
152
153
  }
153
154
  } else {
154
- var _this$options$authOpt2, _this$options$auditsO, _this$options$entitle;
155
+ var _this$options$authOpt2, _this$options$auditsO;
155
156
  this.store = createFronteggStore({
156
157
  context: this.options.contextOptions,
157
158
  appName: this.name
158
159
  }, this, this.options.previewMode, authOptions, {
159
160
  auth: (_this$options$authOpt2 = this.options.authOptions) != null ? _this$options$authOpt2 : {},
160
- audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {},
161
- entitlementsOptions: (_this$options$entitle = this.options.entitlementsOptions) != null ? _this$options$entitle : {}
161
+ audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
162
162
  }, false, this.options.urlStrategy);
163
163
  }
164
164
  AppHolder.setInstance(appName, this);
165
+ this.setEntitlementsOptions(_options.entitlementsOptions);
166
+
167
+ // for feature flags (for entitlements)
168
+ ContextHolder.setAppName(appName);
165
169
  }
170
+
171
+ /**
172
+ * Set entitlements related options in context holder according to frontegg options
173
+ * @param fronteggAppOptions
174
+ */
166
175
  _createClass(FronteggApp, [{
176
+ key: "setEntitlementsOptions",
177
+ value: function setEntitlementsOptions(entitlementsOptions) {
178
+ ContextHolder.setEntitlementsOptions(_extends({}, entitlementsOptions));
179
+ }
180
+ }, {
167
181
  key: "initContainers",
168
182
  value: function () {
169
183
  var _initContainers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(elements) {
@@ -429,10 +443,8 @@ export var FronteggApp = /*#__PURE__*/function () {
429
443
  @throws when entitlement is not enabled via frontegg options
430
444
  */
431
445
  function getFeatureEntitlements(key) {
432
- var _ref4 = this.getEntitlementsFromStore() || {},
433
- entitlements = _ref4.entitlements,
434
- options = _ref4.options;
435
- return _getFeatureEntitlements(entitlements, key, options);
446
+ var entitlements = this.getEntitlementsFromStore();
447
+ return _getFeatureEntitlements(entitlements, key);
436
448
  }
437
449
 
438
450
  /**
@@ -443,10 +455,8 @@ export var FronteggApp = /*#__PURE__*/function () {
443
455
  }, {
444
456
  key: "getPermissionEntitlements",
445
457
  value: function getPermissionEntitlements(key) {
446
- var _ref5 = this.getEntitlementsFromStore() || {},
447
- entitlements = _ref5.entitlements,
448
- options = _ref5.options;
449
- return _getPermissionEntitlements(entitlements, key, options);
458
+ var entitlements = this.getEntitlementsFromStore();
459
+ return _getPermissionEntitlements(entitlements, key);
450
460
  }
451
461
 
452
462
  /**
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.122.0
1
+ /** @license Frontegg v6.123.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.
@@ -131,7 +131,8 @@ var FronteggApp = /*#__PURE__*/function () {
131
131
  _this.updateLocalizations = localizationUpdateFn;
132
132
  };
133
133
  this.getEntitlementsFromStore = function () {
134
- return _this.store.getState().auth.entitlementsState;
134
+ var _this$store$getState$;
135
+ return (_this$store$getState$ = _this.store.getState().auth.user) == null ? void 0 : _this$store$getState$.entitlements;
135
136
  };
136
137
  var appName = (0, _utils.formatName)(name);
137
138
  var customElementName = "frontegg-app-".concat(appName);
@@ -158,19 +159,32 @@ var FronteggApp = /*#__PURE__*/function () {
158
159
  throw Error('Mismatch in store names');
159
160
  }
160
161
  } else {
161
- var _this$options$authOpt2, _this$options$auditsO, _this$options$entitle;
162
+ var _this$options$authOpt2, _this$options$auditsO;
162
163
  this.store = (0, _reduxStore.createFronteggStore)({
163
164
  context: this.options.contextOptions,
164
165
  appName: this.name
165
166
  }, this, this.options.previewMode, authOptions, {
166
167
  auth: (_this$options$authOpt2 = this.options.authOptions) != null ? _this$options$authOpt2 : {},
167
- audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {},
168
- entitlementsOptions: (_this$options$entitle = this.options.entitlementsOptions) != null ? _this$options$entitle : {}
168
+ audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
169
169
  }, false, this.options.urlStrategy);
170
170
  }
171
171
  _AppHolder.AppHolder.setInstance(appName, this);
172
+ this.setEntitlementsOptions(_options.entitlementsOptions);
173
+
174
+ // for feature flags (for entitlements)
175
+ FronteggRestApi.ContextHolder.setAppName(appName);
172
176
  }
177
+
178
+ /**
179
+ * Set entitlements related options in context holder according to frontegg options
180
+ * @param fronteggAppOptions
181
+ */
173
182
  (0, _createClass2["default"])(FronteggApp, [{
183
+ key: "setEntitlementsOptions",
184
+ value: function setEntitlementsOptions(entitlementsOptions) {
185
+ FronteggRestApi.ContextHolder.setEntitlementsOptions((0, _extends2["default"])({}, entitlementsOptions));
186
+ }
187
+ }, {
174
188
  key: "initContainers",
175
189
  value: function () {
176
190
  var _initContainers = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(elements) {
@@ -436,10 +450,8 @@ var FronteggApp = /*#__PURE__*/function () {
436
450
  @throws when entitlement is not enabled via frontegg options
437
451
  */
438
452
  function getFeatureEntitlements(key) {
439
- var _ref4 = this.getEntitlementsFromStore() || {},
440
- entitlements = _ref4.entitlements,
441
- options = _ref4.options;
442
- return (0, _reduxStore.getFeatureEntitlements)(entitlements, key, options);
453
+ var entitlements = this.getEntitlementsFromStore();
454
+ return (0, _reduxStore.getFeatureEntitlements)(entitlements, key);
443
455
  }
444
456
 
445
457
  /**
@@ -450,10 +462,8 @@ var FronteggApp = /*#__PURE__*/function () {
450
462
  }, {
451
463
  key: "getPermissionEntitlements",
452
464
  value: function getPermissionEntitlements(key) {
453
- var _ref5 = this.getEntitlementsFromStore() || {},
454
- entitlements = _ref5.entitlements,
455
- options = _ref5.options;
456
- return (0, _reduxStore.getPermissionEntitlements)(entitlements, key, options);
465
+ var entitlements = this.getEntitlementsFromStore();
466
+ return (0, _reduxStore.getPermissionEntitlements)(entitlements, key);
457
467
  }
458
468
 
459
469
  /**
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.122.0
1
+ /** @license Frontegg v6.123.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.
package/node/version.js CHANGED
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _default = {
8
- cdnVersion: '6.122.0'
8
+ cdnVersion: '6.123.0-alpha.0'
9
9
  };
10
10
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@frontegg/js",
3
- "version": "6.122.0",
3
+ "version": "6.123.0-alpha.0",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
- "@frontegg/types": "6.122.0"
9
+ "@frontegg/types": "6.123.0-alpha.0"
10
10
  },
11
11
  "browserslist": {
12
12
  "production": [