@frontegg/js 6.100.0-alpha.2 → 6.100.0-alpha.3

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.
@@ -1,4 +1,4 @@
1
- import { EnhancedStore } from '@frontegg/redux-store';
1
+ import { EnhancedStore, Entitlements } from '@frontegg/redux-store';
2
2
  import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides } from '@frontegg/types';
3
3
  declare type FronteggAppContainers = {
4
4
  adminPortalEl: HTMLElement;
@@ -44,6 +44,11 @@ export declare class FronteggApp {
44
44
  hideAdminPortal(): void;
45
45
  showCheckoutDialog(opts: FronteggCheckoutDialogOptions): Promise<void>;
46
46
  hideCheckoutDialog(): void;
47
+ /**
48
+ @param keys The requested entitlement keys
49
+ @returns Entitlements contain true/false for every key (state of is key entitled)
50
+ */
51
+ getEntitlements(keys: string[]): Entitlements;
47
52
  close(): void;
48
53
  }
49
54
  export {};
@@ -3,9 +3,9 @@ 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 { createFronteggStore } from '@frontegg/redux-store';
6
+ import { createFronteggStore, getEntitlements as _getEntitlements } from '@frontegg/redux-store';
7
7
  import { Metadata } from '@frontegg/types';
8
- import { formatName } from '../utils';
8
+ import { formatName, restoreSearchParams } from '../utils';
9
9
  import { AppHolder } from '../AppHolder';
10
10
  import { fetch as FronteggFetch } from '@frontegg/rest-api';
11
11
  import { RequestSource } from '@frontegg/rest-api';
@@ -360,7 +360,10 @@ export var FronteggApp = /*#__PURE__*/function () {
360
360
  value: function hideAdminPortal() {
361
361
  try {
362
362
  var _this$adminPortalRend;
363
+ var searchParams = new URLSearchParams(window.location.search);
363
364
  (_this$adminPortalRend = this.adminPortalRenderer) == null ? void 0 : _this$adminPortalRend.unmount();
365
+ // unmount is removing url search params, therefore we need to restore them after unmount
366
+ restoreSearchParams(searchParams);
364
367
  FronteggRestApi.ContextHolder.setRequestSource(null);
365
368
  } catch (e) {
366
369
  console.error('Failed to unmount admin portal', e);
@@ -404,6 +407,18 @@ export var FronteggApp = /*#__PURE__*/function () {
404
407
  console.error('Failed to unmount checkout dialog', e);
405
408
  }
406
409
  }
410
+
411
+ /**
412
+ @param keys The requested entitlement keys
413
+ @returns Entitlements contain true/false for every key (state of is key entitled)
414
+ */
415
+ }, {
416
+ key: "getEntitlements",
417
+ value: function getEntitlements(keys) {
418
+ var _this$store$getState$;
419
+ var entitlements = ((_this$store$getState$ = this.store.getState().auth.entitlementsState) == null ? void 0 : _this$store$getState$.entitlements) || {};
420
+ return _getEntitlements(entitlements, keys);
421
+ }
407
422
  }, {
408
423
  key: "close",
409
424
  value: function close() {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.100.0-alpha.2
1
+ /** @license Frontegg v6.100.0-alpha.3
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.
@@ -367,7 +367,10 @@ var FronteggApp = /*#__PURE__*/function () {
367
367
  value: function hideAdminPortal() {
368
368
  try {
369
369
  var _this$adminPortalRend;
370
+ var searchParams = new URLSearchParams(window.location.search);
370
371
  (_this$adminPortalRend = this.adminPortalRenderer) == null ? void 0 : _this$adminPortalRend.unmount();
372
+ // unmount is removing url search params, therefore we need to restore them after unmount
373
+ (0, _utils.restoreSearchParams)(searchParams);
371
374
  FronteggRestApi.ContextHolder.setRequestSource(null);
372
375
  } catch (e) {
373
376
  console.error('Failed to unmount admin portal', e);
@@ -411,6 +414,18 @@ var FronteggApp = /*#__PURE__*/function () {
411
414
  console.error('Failed to unmount checkout dialog', e);
412
415
  }
413
416
  }
417
+
418
+ /**
419
+ @param keys The requested entitlement keys
420
+ @returns Entitlements contain true/false for every key (state of is key entitled)
421
+ */
422
+ }, {
423
+ key: "getEntitlements",
424
+ value: function getEntitlements(keys) {
425
+ var _this$store$getState$;
426
+ var entitlements = ((_this$store$getState$ = this.store.getState().auth.entitlementsState) == null ? void 0 : _this$store$getState$.entitlements) || {};
427
+ return (0, _reduxStore.getEntitlements)(entitlements, keys);
428
+ }
414
429
  }, {
415
430
  key: "close",
416
431
  value: function close() {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.100.0-alpha.2
1
+ /** @license Frontegg v6.100.0-alpha.3
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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.waitThemeSetter = exports.formatName = exports.createElement = void 0;
6
+ exports.waitThemeSetter = exports.restoreSearchParams = exports.formatName = exports.createElement = void 0;
7
7
  var formatName = function formatName(name) {
8
8
  return name.replace(/\W+/g, ' ').split(/ |\B(?=[A-Z])/).map(function (word) {
9
9
  return word.toLowerCase();
@@ -38,4 +38,14 @@ var waitThemeSetter = function waitThemeSetter(instance) {
38
38
  }, 50);
39
39
  });
40
40
  };
41
- exports.waitThemeSetter = waitThemeSetter;
41
+ exports.waitThemeSetter = waitThemeSetter;
42
+ var restoreSearchParams = function restoreSearchParams(searchParams) {
43
+ var stringifiedSearchParams = searchParams.toString();
44
+ if (!stringifiedSearchParams) {
45
+ return;
46
+ }
47
+ var url = new URL(window.location.href);
48
+ url.search = stringifiedSearchParams;
49
+ window.history.pushState(null, '', url.toString());
50
+ };
51
+ exports.restoreSearchParams = restoreSearchParams;
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.100.0-alpha.2'
8
+ cdnVersion: '6.100.0-alpha.3'
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.100.0-alpha.2",
3
+ "version": "6.100.0-alpha.3",
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.100.0-alpha.2"
9
+ "@frontegg/types": "6.100.0-alpha.3"
10
10
  },
11
11
  "browserslist": {
12
12
  "production": [