@frontegg/js 7.0.0-alpha.2 → 7.0.0-alpha.4

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,12 @@
1
1
  export declare class AdminPortal {
2
2
  static show(name?: string): void;
3
+ static showMultiApp(name?: string): void;
4
+ /**
5
+ * Open the hosted portal must be called synchronously with user interaction
6
+ *
7
+ * @param newTab - open the portal in a new tab = true
8
+ * @param name - the app name = 'default'
9
+ */
10
+ static openHosted(newTab?: boolean, name?: string): void;
3
11
  static hide(name?: string): void;
4
12
  }
@@ -11,6 +11,28 @@ export var AdminPortal = /*#__PURE__*/function () {
11
11
  var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
12
12
  AppHolder.getInstance(name).showAdminPortal();
13
13
  }
14
+ }, {
15
+ key: "showMultiApp",
16
+ value: function showMultiApp() {
17
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
18
+ AppHolder.getInstance(name).showAdminPortal({
19
+ isMultiApp: true
20
+ });
21
+ }
22
+
23
+ /**
24
+ * Open the hosted portal must be called synchronously with user interaction
25
+ *
26
+ * @param newTab - open the portal in a new tab = true
27
+ * @param name - the app name = 'default'
28
+ */
29
+ }, {
30
+ key: "openHosted",
31
+ value: function openHosted() {
32
+ var newTab = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
33
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
34
+ AppHolder.getInstance(name).openHostedAdminPortal(newTab);
35
+ }
14
36
  }, {
15
37
  key: "hide",
16
38
  value: function hide() {
@@ -1,5 +1,5 @@
1
1
  import { FronteggStore, EntitledToOptions, Entitlement, StepUpOptions, IsSteppedUpOptions } from '@frontegg/redux-store';
2
- import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides, LoadEntitlementsCallback } from '@frontegg/types';
2
+ import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides, LoadEntitlementsCallback, ShowAdminPortalOptions, SwitchTenantOptions } from '@frontegg/types';
3
3
  import { IFeatureFlagsAttributes } from '@frontegg/rest-api';
4
4
  import { CustomAttributes } from '@frontegg/entitlements-javascript-commons';
5
5
  declare type FronteggAppContainers = {
@@ -54,7 +54,7 @@ export declare class FronteggApp {
54
54
  * @param flags keys to check
55
55
  * @returns an array of feature flags on/off boolean values
56
56
  */
57
- private queryFeatureFlags;
57
+ queryFeatureFlags: (flags: string[]) => boolean[];
58
58
  initContainers(elements: FronteggAppContainers): Promise<void>;
59
59
  updateLocalizationsSetter: (localizationUpdateFn: (localizations: LocalizationsOverrides) => void) => void;
60
60
  updateMetadata(metadata: FronteggAppOptions['metadata']): void;
@@ -64,7 +64,13 @@ export declare class FronteggApp {
64
64
  logout(): void;
65
65
  loadScript(component: string): Promise<unknown>;
66
66
  loadLoginBox(): Promise<void>;
67
- showAdminPortal(): Promise<void>;
67
+ showAdminPortal(options?: ShowAdminPortalOptions): Promise<void>;
68
+ /**
69
+ * Open the hosted portal must be called synchronously with user interaction
70
+ *
71
+ * @param newTab - open the portal in a new tab = true
72
+ */
73
+ openHostedAdminPortal(newTab?: boolean): void;
68
74
  hideAdminPortal(): void;
69
75
  showCheckoutDialog(opts: FronteggCheckoutDialogOptions): Promise<void>;
70
76
  hideCheckoutDialog(): void;
@@ -117,6 +123,12 @@ export declare class FronteggApp {
117
123
  * @return true when user is stepped up, false otherwise
118
124
  */
119
125
  isSteppedUp(options?: IsSteppedUpOptions): boolean;
126
+ /**
127
+ * Switch tenant
128
+ * @param payload.tenantId tenant id to switch for
129
+ * @param payload.callback optional callback to be called with true / false for success / failure tenant switching operation
130
+ */
131
+ switchTenant(payload: SwitchTenantOptions): void;
120
132
  close(): void;
121
133
  }
122
134
  export {};
@@ -7,7 +7,7 @@ import { getPermissionEntitlements as _getPermissionEntitlements, getFeatureEnti
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, USE_ENTITLEMENTS_V2_ENDPOINT_FF } 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';
@@ -16,6 +16,7 @@ import versions from '../version';
16
16
  import { mockFlagsList } from '../utils/mockFlagsList';
17
17
  import { loadGTM } from './utils';
18
18
  import * as ValtioVanilla from 'valtio/vanilla';
19
+ import deepMerge from 'deepmerge';
19
20
  export var FronteggApp = /*#__PURE__*/function () {
20
21
  function FronteggApp(_options, name) {
21
22
  var _this = this,
@@ -43,36 +44,59 @@ export var FronteggApp = /*#__PURE__*/function () {
43
44
  this.loadingListeners = [];
44
45
  this.updateLocalizations = void 0;
45
46
  this.loadAdminBoxMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
46
- var Get, _data$rows$0$configur, _data$rows, _data$rows$, data;
47
+ var Get, _data$rows, _data$rows$, _data$rows$$configura, _data$rows$$configura2, _data$rows$0$configur, _data$rows2, _data$rows2$, data, overrideUrl, metadata, overrideData;
47
48
  return _regeneratorRuntime.wrap(function _callee$(_context) {
48
49
  while (1) switch (_context.prev = _context.next) {
49
50
  case 0:
50
51
  Get = FronteggFetch.Get;
51
52
  if (_this.options.metadata) {
52
- _context.next = 12;
53
+ _context.next = 25;
53
54
  break;
54
55
  }
55
56
  _context.prev = 2;
56
57
  _context.next = 5;
57
- return Get("/metadata", {
58
+ return Get('/metadata', {
58
59
  entityName: 'adminBox'
59
60
  });
60
61
  case 5:
61
62
  data = _context.sent;
62
- _this.options.metadata = (_data$rows$0$configur = data == null ? void 0 : (_data$rows = data.rows) == null ? void 0 : (_data$rows$ = _data$rows[0]) == null ? void 0 : _data$rows$.configuration) != null ? _data$rows$0$configur : {};
63
- _context.next = 12;
64
- break;
65
- case 9:
63
+ overrideUrl = data == null ? void 0 : (_data$rows = data.rows) == null ? void 0 : (_data$rows$ = _data$rows[0]) == null ? void 0 : (_data$rows$$configura = _data$rows$.configuration) == null ? void 0 : (_data$rows$$configura2 = _data$rows$$configura.metadataOverrides) == null ? void 0 : _data$rows$$configura2.url;
64
+ metadata = (_data$rows$0$configur = data == null ? void 0 : (_data$rows2 = data.rows) == null ? void 0 : (_data$rows2$ = _data$rows2[0]) == null ? void 0 : _data$rows2$.configuration) != null ? _data$rows$0$configur : {};
65
+ if (!overrideUrl) {
66
+ _context.next = 19;
67
+ break;
68
+ }
66
69
  _context.prev = 9;
67
- _context.t0 = _context["catch"](2);
68
- console.error('failed to get admin portal metadata', _context.t0);
70
+ _context.next = 12;
71
+ return Get(overrideUrl, {}, {
72
+ credentials: 'same-origin'
73
+ });
69
74
  case 12:
75
+ overrideData = _context.sent;
76
+ if (overrideData) {
77
+ metadata = deepMerge(metadata, overrideData);
78
+ }
79
+ _context.next = 19;
80
+ break;
81
+ case 16:
82
+ _context.prev = 16;
83
+ _context.t0 = _context["catch"](9);
84
+ console.error('Failed to get metadata overrides', _context.t0);
85
+ case 19:
86
+ _this.options.metadata = metadata;
87
+ _context.next = 25;
88
+ break;
89
+ case 22:
90
+ _context.prev = 22;
91
+ _context.t1 = _context["catch"](2);
92
+ console.error('failed to get admin portal metadata', _context.t1);
93
+ case 25:
70
94
  Metadata.set(_this.options.metadata, _this.name);
71
- case 13:
95
+ case 26:
72
96
  case "end":
73
97
  return _context.stop();
74
98
  }
75
- }, _callee, null, [[2, 9]]);
99
+ }, _callee, null, [[2, 22], [9, 16]]);
76
100
  }));
77
101
  this.requestAuthorize = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
78
102
  var _this$options$authOpt, _this$options$authOpt2;
@@ -162,13 +186,9 @@ export var FronteggApp = /*#__PURE__*/function () {
162
186
  custom: customAttributes,
163
187
  jwt: user
164
188
  };
165
- var _this$queryFeatureFla = _this.queryFeatureFlags([USE_ENTITLEMENTS_V2_ENDPOINT_FF]),
166
- _this$queryFeatureFla2 = _slicedToArray(_this$queryFeatureFla, 1),
167
- useEntitlementsV2 = _this$queryFeatureFla2[0];
168
189
  return {
169
190
  entitlements: entitlements,
170
- attributes: attributes,
171
- isV2: useEntitlementsV2
191
+ attributes: attributes
172
192
  };
173
193
  };
174
194
  var appName = formatName(name);
@@ -414,31 +434,54 @@ export var FronteggApp = /*#__PURE__*/function () {
414
434
  }, {
415
435
  key: "showAdminPortal",
416
436
  value: function () {
417
- var _showAdminPortal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
418
- var FronteggAdminPortal;
437
+ var _showAdminPortal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
438
+ var _ref4, isMultiApp, _this$queryFeatureFla, _this$queryFeatureFla2, multiAppsFlag, FronteggAdminPortal;
419
439
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
420
440
  while (1) switch (_context6.prev = _context6.next) {
421
441
  case 0:
442
+ _ref4 = options != null ? options : {
443
+ isMultiApp: false
444
+ }, isMultiApp = _ref4.isMultiApp;
445
+ _this$queryFeatureFla = this.queryFeatureFlags(['multi-apps-admin-portal']), _this$queryFeatureFla2 = _slicedToArray(_this$queryFeatureFla, 1), multiAppsFlag = _this$queryFeatureFla2[0];
422
446
  FronteggRestApi.ContextHolder.setRequestSource(RequestSource.AdminPortal);
423
- _context6.next = 3;
447
+ _context6.next = 5;
424
448
  return this.loadScript('FronteggAdminPortal');
425
- case 3:
449
+ case 5:
426
450
  FronteggAdminPortal = _context6.sent;
427
451
  this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
428
452
  injector: this,
429
- options: this.options
453
+ options: Object.assign({
454
+ isMultiApp: multiAppsFlag && isMultiApp
455
+ }, this.options)
430
456
  });
431
- case 5:
457
+ case 7:
432
458
  case "end":
433
459
  return _context6.stop();
434
460
  }
435
461
  }, _callee6, this);
436
462
  }));
437
- function showAdminPortal() {
463
+ function showAdminPortal(_x2) {
438
464
  return _showAdminPortal.apply(this, arguments);
439
465
  }
440
466
  return showAdminPortal;
441
467
  }()
468
+ /**
469
+ * Open the hosted portal must be called synchronously with user interaction
470
+ *
471
+ * @param newTab - open the portal in a new tab = true
472
+ */
473
+ }, {
474
+ key: "openHostedAdminPortal",
475
+ value: function openHostedAdminPortal() {
476
+ var newTab = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
477
+ var baseUrl = this.options.contextOptions.baseUrl;
478
+ var hostedPortalUrl = "".concat(baseUrl, "/oauth/portal");
479
+ if (newTab) {
480
+ window.open(hostedPortalUrl, '_blank');
481
+ return;
482
+ }
483
+ window.location.href = hostedPortalUrl;
484
+ }
442
485
  }, {
443
486
  key: "hideAdminPortal",
444
487
  value: function hideAdminPortal() {
@@ -476,7 +519,7 @@ export var FronteggApp = /*#__PURE__*/function () {
476
519
  }
477
520
  }, _callee7, this);
478
521
  }));
479
- function showCheckoutDialog(_x2) {
522
+ function showCheckoutDialog(_x3) {
480
523
  return _showCheckoutDialog.apply(this, arguments);
481
524
  }
482
525
  return showCheckoutDialog;
@@ -507,9 +550,8 @@ export var FronteggApp = /*#__PURE__*/function () {
507
550
  function getFeatureEntitlements(key, customAttributes) {
508
551
  var _this$getEntitlements = this.getEntitlementsQueryData(customAttributes),
509
552
  entitlements = _this$getEntitlements.entitlements,
510
- attributes = _this$getEntitlements.attributes,
511
- isV2 = _this$getEntitlements.isV2;
512
- return _getFeatureEntitlements(entitlements, key, attributes, isV2);
553
+ attributes = _this$getEntitlements.attributes;
554
+ return _getFeatureEntitlements(entitlements, key, attributes);
513
555
  }
514
556
 
515
557
  /**
@@ -523,9 +565,8 @@ export var FronteggApp = /*#__PURE__*/function () {
523
565
  value: function getPermissionEntitlements(key, customAttributes) {
524
566
  var _this$getEntitlements2 = this.getEntitlementsQueryData(customAttributes),
525
567
  entitlements = _this$getEntitlements2.entitlements,
526
- attributes = _this$getEntitlements2.attributes,
527
- isV2 = _this$getEntitlements2.isV2;
528
- return _getPermissionEntitlements(entitlements, key, attributes, isV2);
568
+ attributes = _this$getEntitlements2.attributes;
569
+ return _getPermissionEntitlements(entitlements, key, attributes);
529
570
  }
530
571
 
531
572
  /**
@@ -567,9 +608,9 @@ export var FronteggApp = /*#__PURE__*/function () {
567
608
  key: "stepUp",
568
609
  value: function stepUp(options) {
569
610
  var state = this.store.getState();
570
- var _ref4 = (state == null ? void 0 : state.auth) || {},
571
- hostedLoginBox = _ref4.hostedLoginBox,
572
- stepUpUrl = _ref4.routes.stepUpUrl;
611
+ var _ref5 = (state == null ? void 0 : state.auth) || {},
612
+ hostedLoginBox = _ref5.hostedLoginBox,
613
+ stepUpUrl = _ref5.routes.stepUpUrl;
573
614
  if (hostedLoginBox) {
574
615
  this.store.dispatch({
575
616
  type: 'auth/stepUpHostedLogin',
@@ -589,10 +630,24 @@ export var FronteggApp = /*#__PURE__*/function () {
589
630
  value: function isSteppedUp() {
590
631
  var _this$store$getState;
591
632
  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;
633
+ var _ref6 = ((_this$store$getState = this.store.getState()) == null ? void 0 : _this$store$getState.auth) || {},
634
+ user = _ref6.user;
594
635
  return _isSteppedUp(user, options);
595
636
  }
637
+
638
+ /**
639
+ * Switch tenant
640
+ * @param payload.tenantId tenant id to switch for
641
+ * @param payload.callback optional callback to be called with true / false for success / failure tenant switching operation
642
+ */
643
+ }, {
644
+ key: "switchTenant",
645
+ value: function switchTenant(payload) {
646
+ this.store.dispatch({
647
+ type: 'auth/switchTenant',
648
+ payload: payload
649
+ });
650
+ }
596
651
  }, {
597
652
  key: "close",
598
653
  value: function close() {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.0.0-alpha.2
1
+ /** @license Frontegg v7.0.0-alpha.4
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.
@@ -18,6 +18,28 @@ var AdminPortal = /*#__PURE__*/function () {
18
18
  var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
19
19
  _AppHolder.AppHolder.getInstance(name).showAdminPortal();
20
20
  }
21
+ }, {
22
+ key: "showMultiApp",
23
+ value: function showMultiApp() {
24
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
25
+ _AppHolder.AppHolder.getInstance(name).showAdminPortal({
26
+ isMultiApp: true
27
+ });
28
+ }
29
+
30
+ /**
31
+ * Open the hosted portal must be called synchronously with user interaction
32
+ *
33
+ * @param newTab - open the portal in a new tab = true
34
+ * @param name - the app name = 'default'
35
+ */
36
+ }, {
37
+ key: "openHosted",
38
+ value: function openHosted() {
39
+ var newTab = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
40
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
41
+ _AppHolder.AppHolder.getInstance(name).openHostedAdminPortal(newTab);
42
+ }
21
43
  }, {
22
44
  key: "hide",
23
45
  value: function hide() {
@@ -20,6 +20,7 @@ var _version = _interopRequireDefault(require("../version"));
20
20
  var _mockFlagsList = require("../utils/mockFlagsList");
21
21
  var _utils2 = require("./utils");
22
22
  var ValtioVanilla = _interopRequireWildcard(require("valtio/vanilla"));
23
+ var _deepmerge = _interopRequireDefault(require("deepmerge"));
23
24
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
26
  var FronteggApp = /*#__PURE__*/function () {
@@ -49,36 +50,59 @@ var FronteggApp = /*#__PURE__*/function () {
49
50
  this.loadingListeners = [];
50
51
  this.updateLocalizations = void 0;
51
52
  this.loadAdminBoxMetadata = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
52
- var Get, _data$rows$0$configur, _data$rows, _data$rows$, data;
53
+ var Get, _data$rows, _data$rows$, _data$rows$$configura, _data$rows$$configura2, _data$rows$0$configur, _data$rows2, _data$rows2$, data, overrideUrl, metadata, overrideData;
53
54
  return _regenerator["default"].wrap(function _callee$(_context) {
54
55
  while (1) switch (_context.prev = _context.next) {
55
56
  case 0:
56
57
  Get = FronteggRestApi.fetch.Get;
57
58
  if (_this.options.metadata) {
58
- _context.next = 12;
59
+ _context.next = 25;
59
60
  break;
60
61
  }
61
62
  _context.prev = 2;
62
63
  _context.next = 5;
63
- return Get("/metadata", {
64
+ return Get('/metadata', {
64
65
  entityName: 'adminBox'
65
66
  });
66
67
  case 5:
67
68
  data = _context.sent;
68
- _this.options.metadata = (_data$rows$0$configur = data == null ? void 0 : (_data$rows = data.rows) == null ? void 0 : (_data$rows$ = _data$rows[0]) == null ? void 0 : _data$rows$.configuration) != null ? _data$rows$0$configur : {};
69
- _context.next = 12;
70
- break;
71
- case 9:
69
+ overrideUrl = data == null ? void 0 : (_data$rows = data.rows) == null ? void 0 : (_data$rows$ = _data$rows[0]) == null ? void 0 : (_data$rows$$configura = _data$rows$.configuration) == null ? void 0 : (_data$rows$$configura2 = _data$rows$$configura.metadataOverrides) == null ? void 0 : _data$rows$$configura2.url;
70
+ metadata = (_data$rows$0$configur = data == null ? void 0 : (_data$rows2 = data.rows) == null ? void 0 : (_data$rows2$ = _data$rows2[0]) == null ? void 0 : _data$rows2$.configuration) != null ? _data$rows$0$configur : {};
71
+ if (!overrideUrl) {
72
+ _context.next = 19;
73
+ break;
74
+ }
72
75
  _context.prev = 9;
73
- _context.t0 = _context["catch"](2);
74
- console.error('failed to get admin portal metadata', _context.t0);
76
+ _context.next = 12;
77
+ return Get(overrideUrl, {}, {
78
+ credentials: 'same-origin'
79
+ });
75
80
  case 12:
81
+ overrideData = _context.sent;
82
+ if (overrideData) {
83
+ metadata = (0, _deepmerge["default"])(metadata, overrideData);
84
+ }
85
+ _context.next = 19;
86
+ break;
87
+ case 16:
88
+ _context.prev = 16;
89
+ _context.t0 = _context["catch"](9);
90
+ console.error('Failed to get metadata overrides', _context.t0);
91
+ case 19:
92
+ _this.options.metadata = metadata;
93
+ _context.next = 25;
94
+ break;
95
+ case 22:
96
+ _context.prev = 22;
97
+ _context.t1 = _context["catch"](2);
98
+ console.error('failed to get admin portal metadata', _context.t1);
99
+ case 25:
76
100
  FronteggTypes.Metadata.set(_this.options.metadata, _this.name);
77
- case 13:
101
+ case 26:
78
102
  case "end":
79
103
  return _context.stop();
80
104
  }
81
- }, _callee, null, [[2, 9]]);
105
+ }, _callee, null, [[2, 22], [9, 16]]);
82
106
  }));
83
107
  this.requestAuthorize = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
84
108
  var _this$options$authOpt, _this$options$authOpt2;
@@ -168,13 +192,9 @@ var FronteggApp = /*#__PURE__*/function () {
168
192
  custom: customAttributes,
169
193
  jwt: user
170
194
  };
171
- var _this$queryFeatureFla = _this.queryFeatureFlags([FronteggRestApi.USE_ENTITLEMENTS_V2_ENDPOINT_FF]),
172
- _this$queryFeatureFla2 = (0, _slicedToArray2["default"])(_this$queryFeatureFla, 1),
173
- useEntitlementsV2 = _this$queryFeatureFla2[0];
174
195
  return {
175
196
  entitlements: entitlements,
176
- attributes: attributes,
177
- isV2: useEntitlementsV2
197
+ attributes: attributes
178
198
  };
179
199
  };
180
200
  var appName = (0, _utils.formatName)(name);
@@ -420,31 +440,54 @@ var FronteggApp = /*#__PURE__*/function () {
420
440
  }, {
421
441
  key: "showAdminPortal",
422
442
  value: function () {
423
- var _showAdminPortal = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
424
- var FronteggAdminPortal;
443
+ var _showAdminPortal = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(options) {
444
+ var _ref4, isMultiApp, _this$queryFeatureFla, _this$queryFeatureFla2, multiAppsFlag, FronteggAdminPortal;
425
445
  return _regenerator["default"].wrap(function _callee6$(_context6) {
426
446
  while (1) switch (_context6.prev = _context6.next) {
427
447
  case 0:
448
+ _ref4 = options != null ? options : {
449
+ isMultiApp: false
450
+ }, isMultiApp = _ref4.isMultiApp;
451
+ _this$queryFeatureFla = this.queryFeatureFlags(['multi-apps-admin-portal']), _this$queryFeatureFla2 = (0, _slicedToArray2["default"])(_this$queryFeatureFla, 1), multiAppsFlag = _this$queryFeatureFla2[0];
428
452
  FronteggRestApi.ContextHolder.setRequestSource(FronteggRestApi.RequestSource.AdminPortal);
429
- _context6.next = 3;
453
+ _context6.next = 5;
430
454
  return this.loadScript('FronteggAdminPortal');
431
- case 3:
455
+ case 5:
432
456
  FronteggAdminPortal = _context6.sent;
433
457
  this.adminPortalRenderer = FronteggAdminPortal.render(this.adminPortalEl, {
434
458
  injector: this,
435
- options: this.options
459
+ options: Object.assign({
460
+ isMultiApp: multiAppsFlag && isMultiApp
461
+ }, this.options)
436
462
  });
437
- case 5:
463
+ case 7:
438
464
  case "end":
439
465
  return _context6.stop();
440
466
  }
441
467
  }, _callee6, this);
442
468
  }));
443
- function showAdminPortal() {
469
+ function showAdminPortal(_x2) {
444
470
  return _showAdminPortal.apply(this, arguments);
445
471
  }
446
472
  return showAdminPortal;
447
473
  }()
474
+ /**
475
+ * Open the hosted portal must be called synchronously with user interaction
476
+ *
477
+ * @param newTab - open the portal in a new tab = true
478
+ */
479
+ }, {
480
+ key: "openHostedAdminPortal",
481
+ value: function openHostedAdminPortal() {
482
+ var newTab = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
483
+ var baseUrl = this.options.contextOptions.baseUrl;
484
+ var hostedPortalUrl = "".concat(baseUrl, "/oauth/portal");
485
+ if (newTab) {
486
+ window.open(hostedPortalUrl, '_blank');
487
+ return;
488
+ }
489
+ window.location.href = hostedPortalUrl;
490
+ }
448
491
  }, {
449
492
  key: "hideAdminPortal",
450
493
  value: function hideAdminPortal() {
@@ -482,7 +525,7 @@ var FronteggApp = /*#__PURE__*/function () {
482
525
  }
483
526
  }, _callee7, this);
484
527
  }));
485
- function showCheckoutDialog(_x2) {
528
+ function showCheckoutDialog(_x3) {
486
529
  return _showCheckoutDialog.apply(this, arguments);
487
530
  }
488
531
  return showCheckoutDialog;
@@ -513,9 +556,8 @@ var FronteggApp = /*#__PURE__*/function () {
513
556
  function getFeatureEntitlements(key, customAttributes) {
514
557
  var _this$getEntitlements = this.getEntitlementsQueryData(customAttributes),
515
558
  entitlements = _this$getEntitlements.entitlements,
516
- attributes = _this$getEntitlements.attributes,
517
- isV2 = _this$getEntitlements.isV2;
518
- return (0, FronteggReduxStore.getFeatureEntitlements)(entitlements, key, attributes, isV2);
559
+ attributes = _this$getEntitlements.attributes;
560
+ return (0, FronteggReduxStore.getFeatureEntitlements)(entitlements, key, attributes);
519
561
  }
520
562
 
521
563
  /**
@@ -529,9 +571,8 @@ var FronteggApp = /*#__PURE__*/function () {
529
571
  value: function getPermissionEntitlements(key, customAttributes) {
530
572
  var _this$getEntitlements2 = this.getEntitlementsQueryData(customAttributes),
531
573
  entitlements = _this$getEntitlements2.entitlements,
532
- attributes = _this$getEntitlements2.attributes,
533
- isV2 = _this$getEntitlements2.isV2;
534
- return (0, FronteggReduxStore.getPermissionEntitlements)(entitlements, key, attributes, isV2);
574
+ attributes = _this$getEntitlements2.attributes;
575
+ return (0, FronteggReduxStore.getPermissionEntitlements)(entitlements, key, attributes);
535
576
  }
536
577
 
537
578
  /**
@@ -573,9 +614,9 @@ var FronteggApp = /*#__PURE__*/function () {
573
614
  key: "stepUp",
574
615
  value: function stepUp(options) {
575
616
  var state = this.store.getState();
576
- var _ref4 = (state == null ? void 0 : state.auth) || {},
577
- hostedLoginBox = _ref4.hostedLoginBox,
578
- stepUpUrl = _ref4.routes.stepUpUrl;
617
+ var _ref5 = (state == null ? void 0 : state.auth) || {},
618
+ hostedLoginBox = _ref5.hostedLoginBox,
619
+ stepUpUrl = _ref5.routes.stepUpUrl;
579
620
  if (hostedLoginBox) {
580
621
  this.store.dispatch({
581
622
  type: 'auth/stepUpHostedLogin',
@@ -595,10 +636,24 @@ var FronteggApp = /*#__PURE__*/function () {
595
636
  value: function isSteppedUp() {
596
637
  var _this$store$getState;
597
638
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
598
- var _ref5 = ((_this$store$getState = this.store.getState()) == null ? void 0 : _this$store$getState.auth) || {},
599
- user = _ref5.user;
639
+ var _ref6 = ((_this$store$getState = this.store.getState()) == null ? void 0 : _this$store$getState.auth) || {},
640
+ user = _ref6.user;
600
641
  return (0, FronteggReduxStore.isSteppedUp)(user, options);
601
642
  }
643
+
644
+ /**
645
+ * Switch tenant
646
+ * @param payload.tenantId tenant id to switch for
647
+ * @param payload.callback optional callback to be called with true / false for success / failure tenant switching operation
648
+ */
649
+ }, {
650
+ key: "switchTenant",
651
+ value: function switchTenant(payload) {
652
+ this.store.dispatch({
653
+ type: 'auth/switchTenant',
654
+ payload: payload
655
+ });
656
+ }
602
657
  }, {
603
658
  key: "close",
604
659
  value: function close() {
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.0.0-alpha.2
1
+ /** @license Frontegg v7.0.0-alpha.4
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: '7.0.0-alpha.2'
8
+ cdnVersion: '7.0.0-alpha.4'
9
9
  };
10
10
  exports["default"] = _default;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@frontegg/js",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.0.0-alpha.4",
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": "7.0.0-alpha.2"
9
+ "@frontegg/types": "7.0.0-alpha.4"
10
10
  },
11
11
  "browserslist": {
12
12
  "production": [