@frontegg/js 6.117.0-alpha.1 → 6.118.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.
- package/FronteggApp/FronteggApp.d.ts +21 -4
- package/FronteggApp/FronteggApp.js +48 -9
- package/index.js +1 -1
- package/node/FronteggApp/FronteggApp.js +47 -8
- package/node/index.js +1 -1
- package/node/version.js +1 -1
- package/package.json +2 -2
- package/umd/frontegg.development.js +544 -177
- package/umd/frontegg.production.min.js +1 -1
- package/umd/frontegg.production.min.js.LICENSE.txt +1 -1
- package/version.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnhancedStore,
|
|
1
|
+
import { EnhancedStore, EntitledToOptions, Entitlement } from '@frontegg/redux-store';
|
|
2
2
|
import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides } from '@frontegg/types';
|
|
3
3
|
declare type FronteggAppContainers = {
|
|
4
4
|
adminPortalEl: HTMLElement;
|
|
@@ -45,10 +45,27 @@ export declare class FronteggApp {
|
|
|
45
45
|
showCheckoutDialog(opts: FronteggCheckoutDialogOptions): Promise<void>;
|
|
46
46
|
hideCheckoutDialog(): void;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
* @returns entitlements store data
|
|
49
|
+
*/
|
|
50
|
+
private getEntitlementsFromStore;
|
|
51
|
+
/**
|
|
52
|
+
@param key
|
|
53
|
+
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
54
|
+
@throws when entitlement is not enabled via frontegg options
|
|
55
|
+
*/
|
|
56
|
+
getFeatureEntitlements(key: string): Entitlement;
|
|
57
|
+
/**
|
|
58
|
+
@param key
|
|
59
|
+
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
60
|
+
@throws when entitlement is not enabled via frontegg options
|
|
61
|
+
*/
|
|
62
|
+
getPermissionEntitlements(key: string): Entitlement;
|
|
63
|
+
/**
|
|
64
|
+
@param options - including permission or feature key
|
|
65
|
+
@returns if the user is entitled to the given permission or feature. Attaching the justification if not
|
|
66
|
+
@throws when entitlement is not enabled via frontegg options
|
|
50
67
|
*/
|
|
51
|
-
getEntitlements(
|
|
68
|
+
getEntitlements(options: EntitledToOptions): Entitlement;
|
|
52
69
|
close(): void;
|
|
53
70
|
}
|
|
54
71
|
export {};
|
|
@@ -3,7 +3,7 @@ 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,
|
|
6
|
+
import { createFronteggStore, getPermissionEntitlements as _getPermissionEntitlements, getFeatureEntitlements as _getFeatureEntitlements } from '@frontegg/redux-store';
|
|
7
7
|
import { Metadata } from '@frontegg/types';
|
|
8
8
|
import { formatName, restoreSearchParams } from '../utils';
|
|
9
9
|
import { AppHolder } from '../AppHolder';
|
|
@@ -123,6 +123,9 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
123
123
|
this.updateLocalizationsSetter = function (localizationUpdateFn) {
|
|
124
124
|
_this.updateLocalizations = localizationUpdateFn;
|
|
125
125
|
};
|
|
126
|
+
this.getEntitlementsFromStore = function () {
|
|
127
|
+
return _this.store.getState().auth.entitlementsState;
|
|
128
|
+
};
|
|
126
129
|
var appName = formatName(name);
|
|
127
130
|
var customElementName = "frontegg-app-".concat(appName);
|
|
128
131
|
this.iframeRendering = iframeRendering;
|
|
@@ -148,13 +151,14 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
148
151
|
throw Error('Mismatch in store names');
|
|
149
152
|
}
|
|
150
153
|
} else {
|
|
151
|
-
var _this$options$authOpt2, _this$options$auditsO;
|
|
154
|
+
var _this$options$authOpt2, _this$options$auditsO, _this$options$entitle;
|
|
152
155
|
this.store = createFronteggStore({
|
|
153
156
|
context: this.options.contextOptions,
|
|
154
157
|
appName: this.name
|
|
155
158
|
}, this, this.options.previewMode, authOptions, {
|
|
156
159
|
auth: (_this$options$authOpt2 = this.options.authOptions) != null ? _this$options$authOpt2 : {},
|
|
157
|
-
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
160
|
+
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {},
|
|
161
|
+
entitlementsOptions: (_this$options$entitle = this.options.entitlementsOptions) != null ? _this$options$entitle : {}
|
|
158
162
|
}, false, this.options.urlStrategy);
|
|
159
163
|
}
|
|
160
164
|
AppHolder.setInstance(appName, this);
|
|
@@ -414,15 +418,50 @@ export var FronteggApp = /*#__PURE__*/function () {
|
|
|
414
418
|
}
|
|
415
419
|
|
|
416
420
|
/**
|
|
417
|
-
|
|
418
|
-
|
|
421
|
+
* @returns entitlements store data
|
|
422
|
+
*/
|
|
423
|
+
}, {
|
|
424
|
+
key: "getFeatureEntitlements",
|
|
425
|
+
value:
|
|
426
|
+
/**
|
|
427
|
+
@param key
|
|
428
|
+
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
429
|
+
@throws when entitlement is not enabled via frontegg options
|
|
430
|
+
*/
|
|
431
|
+
function getFeatureEntitlements(key) {
|
|
432
|
+
var _ref4 = this.getEntitlementsFromStore() || {},
|
|
433
|
+
entitlements = _ref4.entitlements,
|
|
434
|
+
options = _ref4.options;
|
|
435
|
+
return _getFeatureEntitlements(entitlements, key, options);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
@param key
|
|
440
|
+
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
441
|
+
@throws when entitlement is not enabled via frontegg options
|
|
442
|
+
*/
|
|
443
|
+
}, {
|
|
444
|
+
key: "getPermissionEntitlements",
|
|
445
|
+
value: function getPermissionEntitlements(key) {
|
|
446
|
+
var _ref5 = this.getEntitlementsFromStore() || {},
|
|
447
|
+
entitlements = _ref5.entitlements,
|
|
448
|
+
options = _ref5.options;
|
|
449
|
+
return _getPermissionEntitlements(entitlements, key, options);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
@param options - including permission or feature key
|
|
454
|
+
@returns if the user is entitled to the given permission or feature. Attaching the justification if not
|
|
455
|
+
@throws when entitlement is not enabled via frontegg options
|
|
419
456
|
*/
|
|
420
457
|
}, {
|
|
421
458
|
key: "getEntitlements",
|
|
422
|
-
value: function getEntitlements(
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
459
|
+
value: function getEntitlements(options) {
|
|
460
|
+
// we use permissionKey (options key) to decide if the user is using permission key or feature key
|
|
461
|
+
if ('permissionKey' in options) {
|
|
462
|
+
return this.getPermissionEntitlements(options.permissionKey);
|
|
463
|
+
}
|
|
464
|
+
return this.getFeatureEntitlements(options.featureKey);
|
|
426
465
|
}
|
|
427
466
|
}, {
|
|
428
467
|
key: "close",
|
package/index.js
CHANGED
|
@@ -130,6 +130,9 @@ var FronteggApp = /*#__PURE__*/function () {
|
|
|
130
130
|
this.updateLocalizationsSetter = function (localizationUpdateFn) {
|
|
131
131
|
_this.updateLocalizations = localizationUpdateFn;
|
|
132
132
|
};
|
|
133
|
+
this.getEntitlementsFromStore = function () {
|
|
134
|
+
return _this.store.getState().auth.entitlementsState;
|
|
135
|
+
};
|
|
133
136
|
var appName = (0, _utils.formatName)(name);
|
|
134
137
|
var customElementName = "frontegg-app-".concat(appName);
|
|
135
138
|
this.iframeRendering = iframeRendering;
|
|
@@ -155,13 +158,14 @@ var FronteggApp = /*#__PURE__*/function () {
|
|
|
155
158
|
throw Error('Mismatch in store names');
|
|
156
159
|
}
|
|
157
160
|
} else {
|
|
158
|
-
var _this$options$authOpt2, _this$options$auditsO;
|
|
161
|
+
var _this$options$authOpt2, _this$options$auditsO, _this$options$entitle;
|
|
159
162
|
this.store = (0, _reduxStore.createFronteggStore)({
|
|
160
163
|
context: this.options.contextOptions,
|
|
161
164
|
appName: this.name
|
|
162
165
|
}, this, this.options.previewMode, authOptions, {
|
|
163
166
|
auth: (_this$options$authOpt2 = this.options.authOptions) != null ? _this$options$authOpt2 : {},
|
|
164
|
-
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {}
|
|
167
|
+
audits: (_this$options$auditsO = this.options.auditsOptions) != null ? _this$options$auditsO : {},
|
|
168
|
+
entitlementsOptions: (_this$options$entitle = this.options.entitlementsOptions) != null ? _this$options$entitle : {}
|
|
165
169
|
}, false, this.options.urlStrategy);
|
|
166
170
|
}
|
|
167
171
|
_AppHolder.AppHolder.setInstance(appName, this);
|
|
@@ -421,15 +425,50 @@ var FronteggApp = /*#__PURE__*/function () {
|
|
|
421
425
|
}
|
|
422
426
|
|
|
423
427
|
/**
|
|
424
|
-
|
|
425
|
-
|
|
428
|
+
* @returns entitlements store data
|
|
429
|
+
*/
|
|
430
|
+
}, {
|
|
431
|
+
key: "getFeatureEntitlements",
|
|
432
|
+
value:
|
|
433
|
+
/**
|
|
434
|
+
@param key
|
|
435
|
+
@returns if the user is entitled to the given feature. Attaching the justification if not
|
|
436
|
+
@throws when entitlement is not enabled via frontegg options
|
|
437
|
+
*/
|
|
438
|
+
function getFeatureEntitlements(key) {
|
|
439
|
+
var _ref4 = this.getEntitlementsFromStore() || {},
|
|
440
|
+
entitlements = _ref4.entitlements,
|
|
441
|
+
options = _ref4.options;
|
|
442
|
+
return (0, _reduxStore.getFeatureEntitlements)(entitlements, key, options);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
@param key
|
|
447
|
+
@returns if the user is entitled to the given permission. Attaching the justification if not
|
|
448
|
+
@throws when entitlement is not enabled via frontegg options
|
|
449
|
+
*/
|
|
450
|
+
}, {
|
|
451
|
+
key: "getPermissionEntitlements",
|
|
452
|
+
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);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
@param options - including permission or feature key
|
|
461
|
+
@returns if the user is entitled to the given permission or feature. Attaching the justification if not
|
|
462
|
+
@throws when entitlement is not enabled via frontegg options
|
|
426
463
|
*/
|
|
427
464
|
}, {
|
|
428
465
|
key: "getEntitlements",
|
|
429
|
-
value: function getEntitlements(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
466
|
+
value: function getEntitlements(options) {
|
|
467
|
+
// we use permissionKey (options key) to decide if the user is using permission key or feature key
|
|
468
|
+
if ('permissionKey' in options) {
|
|
469
|
+
return this.getPermissionEntitlements(options.permissionKey);
|
|
470
|
+
}
|
|
471
|
+
return this.getFeatureEntitlements(options.featureKey);
|
|
433
472
|
}
|
|
434
473
|
}, {
|
|
435
474
|
key: "close",
|
package/node/index.js
CHANGED
package/node/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/js",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.118.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.
|
|
9
|
+
"@frontegg/types": "6.118.0"
|
|
10
10
|
},
|
|
11
11
|
"browserslist": {
|
|
12
12
|
"production": [
|