@frontegg/angular 6.13.0-alpha.7274991440 → 6.13.0-alpha.7347624886
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/bundles/frontegg-angular.umd.js +111 -56
- package/bundles/frontegg-angular.umd.js.map +1 -1
- package/esm2015/lib/frontegg-app.module.js +3 -1
- package/esm2015/lib/frontegg-auth.service.js +25 -6
- package/esm2015/lib/frontegg-entitlements.service.js +27 -51
- package/esm2015/lib/frontegg-user-subscription.service.js +65 -0
- package/fesm2015/frontegg-angular.js +110 -55
- package/fesm2015/frontegg-angular.js.map +1 -1
- package/lib/frontegg-app.module.d.ts.map +1 -1
- package/lib/frontegg-auth.service.d.ts +16 -3
- package/lib/frontegg-auth.service.d.ts.map +1 -1
- package/lib/frontegg-entitlements.service.d.ts +4 -17
- package/lib/frontegg-entitlements.service.d.ts.map +1 -1
- package/lib/frontegg-user-subscription.service.d.ts +31 -0
- package/lib/frontegg-user-subscription.service.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -624,11 +624,75 @@
|
|
|
624
624
|
}
|
|
625
625
|
};
|
|
626
626
|
|
|
627
|
+
/**
|
|
628
|
+
* A service for managing user state subscription
|
|
629
|
+
* The service gives the ability to subscribe to user state change and get a manipulated data when the user state changes
|
|
630
|
+
*/
|
|
631
|
+
var FronteggUserSubscriptionService = /** @class */ (function () {
|
|
632
|
+
function FronteggUserSubscriptionService(fronteggAppService) {
|
|
633
|
+
var _this = this;
|
|
634
|
+
this.fronteggAppService = fronteggAppService;
|
|
635
|
+
this.userStateSubject = new rxjs.BehaviorSubject(undefined);
|
|
636
|
+
var state = this.fronteggAppService.fronteggApp.store.getState();
|
|
637
|
+
this.updateUserStateIfNeeded(state.auth);
|
|
638
|
+
// Memoized user State
|
|
639
|
+
this.fronteggAppService.fronteggApp.store.subscribe(function () {
|
|
640
|
+
var newState = _this.fronteggAppService.fronteggApp.store.getState();
|
|
641
|
+
_this.updateUserStateIfNeeded(newState.auth);
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Trigger user subject change event if the user reference changes
|
|
646
|
+
* No need for deep equal because we already check it internally
|
|
647
|
+
* @param authState
|
|
648
|
+
*/
|
|
649
|
+
FronteggUserSubscriptionService.prototype.updateUserStateIfNeeded = function (authState) {
|
|
650
|
+
var userState = authState.user;
|
|
651
|
+
if (this.userStateSubject.value === userState) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
this.userStateSubject.next(userState);
|
|
655
|
+
};
|
|
656
|
+
/**
|
|
657
|
+
* The function gives the ability to return a manipulated data of the user state as a subscription.
|
|
658
|
+
*
|
|
659
|
+
* @param dataManipulator Manipulator function that receives user state and returns a manipulated data
|
|
660
|
+
* @param observer For receiving manipulated data result
|
|
661
|
+
* @returns a subscription to be able to unsubscribe
|
|
662
|
+
*/
|
|
663
|
+
FronteggUserSubscriptionService.prototype.getUserManipulatorSubscription = function (dataManipulator, observer) {
|
|
664
|
+
// used for computing the end user result because we don't return the state itself, but a calculated one
|
|
665
|
+
var userSubject = new rxjs.BehaviorSubject(undefined);
|
|
666
|
+
var stateSubscription = this.userStateSubject.subscribe(function (user) {
|
|
667
|
+
userSubject.next(dataManipulator(user));
|
|
668
|
+
});
|
|
669
|
+
// subscribing the consumer observer
|
|
670
|
+
var userResultSubscription = userSubject.asObservable().subscribe(observer);
|
|
671
|
+
// monkey patched to manage both un-subscriptions: state and user manipulated result
|
|
672
|
+
var originalUnsubscribe = userResultSubscription.unsubscribe.bind(userResultSubscription);
|
|
673
|
+
userResultSubscription.unsubscribe = function () {
|
|
674
|
+
originalUnsubscribe();
|
|
675
|
+
stateSubscription.unsubscribe();
|
|
676
|
+
};
|
|
677
|
+
return userResultSubscription;
|
|
678
|
+
};
|
|
679
|
+
return FronteggUserSubscriptionService;
|
|
680
|
+
}());
|
|
681
|
+
FronteggUserSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggUserSubscriptionService, deps: [{ token: FronteggAppService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
682
|
+
FronteggUserSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggUserSubscriptionService, providedIn: 'root' });
|
|
683
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggUserSubscriptionService, decorators: [{
|
|
684
|
+
type: i0.Injectable,
|
|
685
|
+
args: [{
|
|
686
|
+
providedIn: 'root',
|
|
687
|
+
}]
|
|
688
|
+
}], ctorParameters: function () { return [{ type: FronteggAppService }]; } });
|
|
689
|
+
|
|
627
690
|
var FronteggAuthService = /** @class */ (function () {
|
|
628
|
-
function FronteggAuthService(fronteggAppService, router) {
|
|
691
|
+
function FronteggAuthService(fronteggAppService, router, fronteggUserSubscriptionService) {
|
|
629
692
|
var _this = this;
|
|
630
693
|
this.fronteggAppService = fronteggAppService;
|
|
631
694
|
this.router = router;
|
|
695
|
+
this.fronteggUserSubscriptionService = fronteggUserSubscriptionService;
|
|
632
696
|
this.authStateSubject = new rxjs.BehaviorSubject({ isAuthenticated: false, isLoading: true });
|
|
633
697
|
this.acceptInvitationStateSubject = new rxjs.BehaviorSubject({});
|
|
634
698
|
this.accountSettingsStateSubject = new rxjs.BehaviorSubject({});
|
|
@@ -651,6 +715,11 @@
|
|
|
651
715
|
this.isLoadingSubject = new rxjs.BehaviorSubject(true);
|
|
652
716
|
this.isSSOAuthSubject = new rxjs.BehaviorSubject(false);
|
|
653
717
|
this.ssoACSSubject = new rxjs.BehaviorSubject('');
|
|
718
|
+
/**
|
|
719
|
+
* Triggers step up flow
|
|
720
|
+
* @param options.maxAge optional max age
|
|
721
|
+
*/
|
|
722
|
+
this.stepUp = function (options) { return _this.fronteggAppService.fronteggApp.stepUp(options); };
|
|
654
723
|
// Root Actions
|
|
655
724
|
this.setState = function (state) { return _this.dispatchAction('setState', state); };
|
|
656
725
|
this.resetState = function () { return _this.dispatchAction('resetState'); };
|
|
@@ -660,12 +729,15 @@
|
|
|
660
729
|
this.resetLoginState = function () { return _this.dispatchAction('resetLoginState'); };
|
|
661
730
|
this.requestAuthorize = function (firstTime) { return _this.dispatchAction('requestAuthorize', firstTime); };
|
|
662
731
|
this.loginWithRedirect = function (params, shouldRedirectToLogin, firstTime, loginDirectAction) {
|
|
663
|
-
if (shouldRedirectToLogin === void 0) { shouldRedirectToLogin = true; }
|
|
664
|
-
if (firstTime === void 0) { firstTime = false; }
|
|
665
732
|
if (_this.isHostedLoginCallbackRoute()) {
|
|
666
733
|
return;
|
|
667
734
|
}
|
|
668
|
-
_this.dispatchAction('requestHostedLoginAuthorizeV2', {
|
|
735
|
+
_this.dispatchAction('requestHostedLoginAuthorizeV2', {
|
|
736
|
+
additionalParams: params,
|
|
737
|
+
shouldRedirectToLogin: shouldRedirectToLogin !== null && shouldRedirectToLogin !== void 0 ? shouldRedirectToLogin : true,
|
|
738
|
+
firstTime: firstTime !== null && firstTime !== void 0 ? firstTime : false,
|
|
739
|
+
loginDirectAction: loginDirectAction,
|
|
740
|
+
});
|
|
669
741
|
_this.setState({ isLoading: true });
|
|
670
742
|
};
|
|
671
743
|
this.preLogin = function (payload) { return _this.dispatchAction('preLogin', payload); };
|
|
@@ -1033,16 +1105,24 @@
|
|
|
1033
1105
|
var hostedLoginRedirectUrl = this.fronteggAppService.authRoutes.hostedLoginRedirectUrl;
|
|
1034
1106
|
return path.startsWith(hostedLoginRedirectUrl !== null && hostedLoginRedirectUrl !== void 0 ? hostedLoginRedirectUrl : '/oauth/callback');
|
|
1035
1107
|
};
|
|
1108
|
+
/**
|
|
1109
|
+
* @param options.maxAge optional max age
|
|
1110
|
+
* @returns A subscription for step up state - true when user is stepped up, false otherwise
|
|
1111
|
+
*/
|
|
1112
|
+
FronteggAuthService.prototype.isSteppedUp$ = function (observer, options) {
|
|
1113
|
+
var _this = this;
|
|
1114
|
+
return this.fronteggUserSubscriptionService.getUserManipulatorSubscription(function () { return _this.fronteggAppService.fronteggApp.isSteppedUp(options); }, observer);
|
|
1115
|
+
};
|
|
1036
1116
|
return FronteggAuthService;
|
|
1037
1117
|
}());
|
|
1038
|
-
FronteggAuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggAuthService, deps: [{ token: FronteggAppService }, { token: i1__namespace.Router }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1118
|
+
FronteggAuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggAuthService, deps: [{ token: FronteggAppService }, { token: i1__namespace.Router }, { token: FronteggUserSubscriptionService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1039
1119
|
FronteggAuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggAuthService, providedIn: 'root' });
|
|
1040
1120
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggAuthService, decorators: [{
|
|
1041
1121
|
type: i0.Injectable,
|
|
1042
1122
|
args: [{
|
|
1043
1123
|
providedIn: 'root',
|
|
1044
1124
|
}]
|
|
1045
|
-
}], ctorParameters: function () { return [{ type: FronteggAppService }, { type: i1__namespace.Router }]; } });
|
|
1125
|
+
}], ctorParameters: function () { return [{ type: FronteggAppService }, { type: i1__namespace.Router }, { type: FronteggUserSubscriptionService }]; } });
|
|
1046
1126
|
|
|
1047
1127
|
var FronteggAuthGuard = /** @class */ (function (_super) {
|
|
1048
1128
|
__extends(FronteggAuthGuard, _super);
|
|
@@ -1257,53 +1337,10 @@
|
|
|
1257
1337
|
* 3. Load entitlements on demand.
|
|
1258
1338
|
*/
|
|
1259
1339
|
var FronteggEntitlementsService = /** @class */ (function () {
|
|
1260
|
-
function FronteggEntitlementsService(fronteggAppService) {
|
|
1261
|
-
var _this = this;
|
|
1340
|
+
function FronteggEntitlementsService(fronteggAppService, fronteggUserSubscriptionService) {
|
|
1262
1341
|
this.fronteggAppService = fronteggAppService;
|
|
1263
|
-
this.
|
|
1264
|
-
var state = this.fronteggAppService.fronteggApp.store.getState();
|
|
1265
|
-
this.updateUserStateIfNeeded(state.auth);
|
|
1266
|
-
// Memoized entitlements State
|
|
1267
|
-
this.fronteggAppService.fronteggApp.store.subscribe(function () {
|
|
1268
|
-
var newState = _this.fronteggAppService.fronteggApp.store.getState();
|
|
1269
|
-
_this.updateUserStateIfNeeded(newState.auth);
|
|
1270
|
-
});
|
|
1342
|
+
this.fronteggUserSubscriptionService = fronteggUserSubscriptionService;
|
|
1271
1343
|
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Trigger entitlements subject change event if the entitlements reference changes
|
|
1274
|
-
* No need for deep equal because we already check it internally
|
|
1275
|
-
* @param authState
|
|
1276
|
-
*/
|
|
1277
|
-
FronteggEntitlementsService.prototype.updateUserStateIfNeeded = function (authState) {
|
|
1278
|
-
var entitlementsState = authState.user;
|
|
1279
|
-
if (this.userStateSubject.value === entitlementsState) {
|
|
1280
|
-
return;
|
|
1281
|
-
}
|
|
1282
|
-
this.userStateSubject.next(entitlementsState);
|
|
1283
|
-
};
|
|
1284
|
-
/**
|
|
1285
|
-
* The function gives the ability to return a manipulated data of the user state as a subscription.
|
|
1286
|
-
*
|
|
1287
|
-
* @param dataManipulator Manipulator function that receives user state and returns a manipulated data
|
|
1288
|
-
* @param observer For receiving manipulated data result
|
|
1289
|
-
* @returns a subscription to be able to unsubscribe
|
|
1290
|
-
*/
|
|
1291
|
-
FronteggEntitlementsService.prototype.getUserManipulatorSubscription = function (dataManipulator, observer) {
|
|
1292
|
-
// used for computing the entitlements result because we don't return the state itself, but a calculated one
|
|
1293
|
-
var userSubject = new rxjs.BehaviorSubject(undefined);
|
|
1294
|
-
var stateSubscription = this.userStateSubject.subscribe(function (user) {
|
|
1295
|
-
userSubject.next(dataManipulator(user));
|
|
1296
|
-
});
|
|
1297
|
-
// subscribing the consumer observer
|
|
1298
|
-
var userResultSubscription = userSubject.asObservable().subscribe(observer);
|
|
1299
|
-
// monkey patched to manage both un-subscriptions: state and user manipulated result
|
|
1300
|
-
var originalUnsubscribe = userResultSubscription.unsubscribe.bind(userResultSubscription);
|
|
1301
|
-
userResultSubscription.unsubscribe = function () {
|
|
1302
|
-
originalUnsubscribe();
|
|
1303
|
-
stateSubscription.unsubscribe();
|
|
1304
|
-
};
|
|
1305
|
-
return userResultSubscription;
|
|
1306
|
-
};
|
|
1307
1344
|
/**
|
|
1308
1345
|
* @param feature
|
|
1309
1346
|
* @param observer For receiving the feature entitlements result including if the user is entitled to the given feature.
|
|
@@ -1314,7 +1351,13 @@
|
|
|
1314
1351
|
*/
|
|
1315
1352
|
FronteggEntitlementsService.prototype.featureEntitlements$ = function (feature, observer, customAttributes) {
|
|
1316
1353
|
var _this = this;
|
|
1317
|
-
return this.getUserManipulatorSubscription(function () {
|
|
1354
|
+
return this.fronteggUserSubscriptionService.getUserManipulatorSubscription(function (user) {
|
|
1355
|
+
// the entitlemenets-common npm doesn't know to overcome the case of signed out user, then we get console errors
|
|
1356
|
+
if (user) {
|
|
1357
|
+
return _this.fronteggAppService.fronteggApp.getFeatureEntitlements(feature, customAttributes);
|
|
1358
|
+
}
|
|
1359
|
+
return { isEntitled: false, justification: restApi.NotEntitledJustification.MISSING_FEATURE };
|
|
1360
|
+
}, observer);
|
|
1318
1361
|
};
|
|
1319
1362
|
/**
|
|
1320
1363
|
* @param permission
|
|
@@ -1325,7 +1368,12 @@
|
|
|
1325
1368
|
*/
|
|
1326
1369
|
FronteggEntitlementsService.prototype.permissionEntitlements$ = function (permission, observer, customAttributes) {
|
|
1327
1370
|
var _this = this;
|
|
1328
|
-
return this.getUserManipulatorSubscription(function () {
|
|
1371
|
+
return this.fronteggUserSubscriptionService.getUserManipulatorSubscription(function (user) {
|
|
1372
|
+
if (user) {
|
|
1373
|
+
return _this.fronteggAppService.fronteggApp.getPermissionEntitlements(permission, customAttributes);
|
|
1374
|
+
}
|
|
1375
|
+
return { isEntitled: false, justification: restApi.NotEntitledJustification.MISSING_PERMISSION };
|
|
1376
|
+
}, observer);
|
|
1329
1377
|
};
|
|
1330
1378
|
/**
|
|
1331
1379
|
* @param options permissionKey or featureKey in an options object
|
|
@@ -1336,7 +1384,13 @@
|
|
|
1336
1384
|
*/
|
|
1337
1385
|
FronteggEntitlementsService.prototype.entitlements$ = function (options, observer, customAttributes) {
|
|
1338
1386
|
var _this = this;
|
|
1339
|
-
return this.getUserManipulatorSubscription(function () {
|
|
1387
|
+
return this.fronteggUserSubscriptionService.getUserManipulatorSubscription(function (user) {
|
|
1388
|
+
if (user) {
|
|
1389
|
+
return _this.fronteggAppService.fronteggApp.getEntitlements(options, customAttributes);
|
|
1390
|
+
}
|
|
1391
|
+
var justification = 'featureKey' in options ? restApi.NotEntitledJustification.MISSING_FEATURE : restApi.NotEntitledJustification.MISSING_PERMISSION;
|
|
1392
|
+
return { isEntitled: false, justification: justification };
|
|
1393
|
+
}, observer);
|
|
1340
1394
|
};
|
|
1341
1395
|
/**
|
|
1342
1396
|
* Load entitlements data on demand
|
|
@@ -1347,14 +1401,14 @@
|
|
|
1347
1401
|
};
|
|
1348
1402
|
return FronteggEntitlementsService;
|
|
1349
1403
|
}());
|
|
1350
|
-
FronteggEntitlementsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggEntitlementsService, deps: [{ token: FronteggAppService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1404
|
+
FronteggEntitlementsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggEntitlementsService, deps: [{ token: FronteggAppService }, { token: FronteggUserSubscriptionService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
1351
1405
|
FronteggEntitlementsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggEntitlementsService, providedIn: 'root' });
|
|
1352
1406
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FronteggEntitlementsService, decorators: [{
|
|
1353
1407
|
type: i0.Injectable,
|
|
1354
1408
|
args: [{
|
|
1355
1409
|
providedIn: 'root',
|
|
1356
1410
|
}]
|
|
1357
|
-
}], ctorParameters: function () { return [{ type: FronteggAppService }]; } });
|
|
1411
|
+
}], ctorParameters: function () { return [{ type: FronteggAppService }, { type: FronteggUserSubscriptionService }]; } });
|
|
1358
1412
|
|
|
1359
1413
|
var FronteggAppModule = /** @class */ (function () {
|
|
1360
1414
|
function FronteggAppModule() {
|
|
@@ -1369,6 +1423,7 @@
|
|
|
1369
1423
|
FronteggAuthService,
|
|
1370
1424
|
FronteggEntitlementsService,
|
|
1371
1425
|
FronteggSubscriptionService,
|
|
1426
|
+
FronteggUserSubscriptionService,
|
|
1372
1427
|
{
|
|
1373
1428
|
provide: FronteggAppOptionsClass,
|
|
1374
1429
|
useValue: config,
|