@frontegg/angular 6.13.0-alpha.7349472316 → 6.13.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/CHANGELOG.md +523 -0
- package/bundles/frontegg-angular.umd.js +54 -106
- package/bundles/frontegg-angular.umd.js.map +1 -1
- package/esm2015/lib/frontegg-app.module.js +1 -3
- package/esm2015/lib/frontegg-auth.service.js +4 -18
- package/esm2015/lib/frontegg-entitlements.service.js +51 -27
- package/esm2015/sdkVersion.js +2 -2
- package/fesm2015/frontegg-angular.js +54 -104
- 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 +2 -15
- package/lib/frontegg-auth.service.d.ts.map +1 -1
- package/lib/frontegg-entitlements.service.d.ts +17 -4
- package/lib/frontegg-entitlements.service.d.ts.map +1 -1
- package/package.json +2 -2
- package/esm2015/lib/frontegg-user-subscription.service.js +0 -65
- package/lib/frontegg-user-subscription.service.d.ts +0 -31
- package/lib/frontegg-user-subscription.service.d.ts.map +0 -1
|
@@ -6,7 +6,7 @@ import { DefaultUrlSerializer, RouterModule } from '@angular/router';
|
|
|
6
6
|
import { initialize } from '@frontegg/js';
|
|
7
7
|
import { isAuthRoute, authStoreName, subscriptionsStoreName } from '@frontegg/redux-store';
|
|
8
8
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
9
|
-
import { FronteggFrameworks, ContextHolder
|
|
9
|
+
import { FronteggFrameworks, ContextHolder } from '@frontegg/rest-api';
|
|
10
10
|
export { ContextHolder } from '@frontegg/rest-api';
|
|
11
11
|
import angularCoreVersion from '@angular/core/package.json';
|
|
12
12
|
import { __awaiter } from 'tslib';
|
|
@@ -25,7 +25,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
25
25
|
}]
|
|
26
26
|
}] });
|
|
27
27
|
|
|
28
|
-
var sdkVersion = { version: '6.
|
|
28
|
+
var sdkVersion = { version: '6.13.0' };
|
|
29
29
|
|
|
30
30
|
class FronteggAppOptionsClass {
|
|
31
31
|
constructor() {
|
|
@@ -243,72 +243,10 @@ const runNgZoneIfNeeded = (ngZone, fn) => {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
|
|
246
|
-
/**
|
|
247
|
-
* A service for managing user state subscription
|
|
248
|
-
* The service gives the ability to subscribe to user state change and get a manipulated data when the user state changes
|
|
249
|
-
*/
|
|
250
|
-
class FronteggUserSubscriptionService {
|
|
251
|
-
constructor(fronteggAppService) {
|
|
252
|
-
this.fronteggAppService = fronteggAppService;
|
|
253
|
-
this.userStateSubject = new BehaviorSubject(undefined);
|
|
254
|
-
const state = this.fronteggAppService.fronteggApp.store.getState();
|
|
255
|
-
this.updateUserStateIfNeeded(state.auth);
|
|
256
|
-
// Memoized user State
|
|
257
|
-
this.fronteggAppService.fronteggApp.store.subscribe(() => {
|
|
258
|
-
const newState = this.fronteggAppService.fronteggApp.store.getState();
|
|
259
|
-
this.updateUserStateIfNeeded(newState.auth);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Trigger user subject change event if the user reference changes
|
|
264
|
-
* No need for deep equal because we already check it internally
|
|
265
|
-
* @param authState
|
|
266
|
-
*/
|
|
267
|
-
updateUserStateIfNeeded(authState) {
|
|
268
|
-
const userState = authState.user;
|
|
269
|
-
if (this.userStateSubject.value === userState) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
this.userStateSubject.next(userState);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* The function gives the ability to return a manipulated data of the user state as a subscription.
|
|
276
|
-
*
|
|
277
|
-
* @param dataManipulator Manipulator function that receives user state and returns a manipulated data
|
|
278
|
-
* @param observer For receiving manipulated data result
|
|
279
|
-
* @returns a subscription to be able to unsubscribe
|
|
280
|
-
*/
|
|
281
|
-
getUserManipulatorSubscription(dataManipulator, observer) {
|
|
282
|
-
// used for computing the end user result because we don't return the state itself, but a calculated one
|
|
283
|
-
const userSubject = new BehaviorSubject(undefined);
|
|
284
|
-
const stateSubscription = this.userStateSubject.subscribe(user => {
|
|
285
|
-
userSubject.next(dataManipulator(user));
|
|
286
|
-
});
|
|
287
|
-
// subscribing the consumer observer
|
|
288
|
-
const userResultSubscription = userSubject.asObservable().subscribe(observer);
|
|
289
|
-
// monkey patched to manage both un-subscriptions: state and user manipulated result
|
|
290
|
-
const originalUnsubscribe = userResultSubscription.unsubscribe.bind(userResultSubscription);
|
|
291
|
-
userResultSubscription.unsubscribe = () => {
|
|
292
|
-
originalUnsubscribe();
|
|
293
|
-
stateSubscription.unsubscribe();
|
|
294
|
-
};
|
|
295
|
-
return userResultSubscription;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
FronteggUserSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggUserSubscriptionService, deps: [{ token: FronteggAppService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
299
|
-
FronteggUserSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggUserSubscriptionService, providedIn: 'root' });
|
|
300
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggUserSubscriptionService, decorators: [{
|
|
301
|
-
type: Injectable,
|
|
302
|
-
args: [{
|
|
303
|
-
providedIn: 'root',
|
|
304
|
-
}]
|
|
305
|
-
}], ctorParameters: function () { return [{ type: FronteggAppService }]; } });
|
|
306
|
-
|
|
307
246
|
class FronteggAuthService {
|
|
308
|
-
constructor(fronteggAppService, router
|
|
247
|
+
constructor(fronteggAppService, router) {
|
|
309
248
|
this.fronteggAppService = fronteggAppService;
|
|
310
249
|
this.router = router;
|
|
311
|
-
this.fronteggUserSubscriptionService = fronteggUserSubscriptionService;
|
|
312
250
|
this.authStateSubject = new BehaviorSubject({ isAuthenticated: false, isLoading: true });
|
|
313
251
|
this.acceptInvitationStateSubject = new BehaviorSubject({});
|
|
314
252
|
this.accountSettingsStateSubject = new BehaviorSubject({});
|
|
@@ -331,11 +269,6 @@ class FronteggAuthService {
|
|
|
331
269
|
this.isLoadingSubject = new BehaviorSubject(true);
|
|
332
270
|
this.isSSOAuthSubject = new BehaviorSubject(false);
|
|
333
271
|
this.ssoACSSubject = new BehaviorSubject('');
|
|
334
|
-
/**
|
|
335
|
-
* Triggers step up flow
|
|
336
|
-
* @param options.maxAge optional max age
|
|
337
|
-
*/
|
|
338
|
-
this.stepUp = (options) => this.fronteggAppService.fronteggApp.stepUp(options);
|
|
339
272
|
// Root Actions
|
|
340
273
|
this.setState = (state) => this.dispatchAction('setState', state);
|
|
341
274
|
this.resetState = () => this.dispatchAction('resetState');
|
|
@@ -614,22 +547,15 @@ class FronteggAuthService {
|
|
|
614
547
|
const hostedLoginRedirectUrl = this.fronteggAppService.authRoutes.hostedLoginRedirectUrl;
|
|
615
548
|
return path.startsWith(hostedLoginRedirectUrl !== null && hostedLoginRedirectUrl !== void 0 ? hostedLoginRedirectUrl : '/oauth/callback');
|
|
616
549
|
}
|
|
617
|
-
/**
|
|
618
|
-
* @param options.maxAge optional max age
|
|
619
|
-
* @returns A subscription for step up state - true when user is stepped up, false otherwise
|
|
620
|
-
*/
|
|
621
|
-
isSteppedUp$(observer, options) {
|
|
622
|
-
return this.fronteggUserSubscriptionService.getUserManipulatorSubscription(() => { return this.fronteggAppService.fronteggApp.isSteppedUp(options); }, observer);
|
|
623
|
-
}
|
|
624
550
|
}
|
|
625
|
-
FronteggAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggAuthService, deps: [{ token: FronteggAppService }, { token: i1.Router }
|
|
551
|
+
FronteggAuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggAuthService, deps: [{ token: FronteggAppService }, { token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
626
552
|
FronteggAuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggAuthService, providedIn: 'root' });
|
|
627
553
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggAuthService, decorators: [{
|
|
628
554
|
type: Injectable,
|
|
629
555
|
args: [{
|
|
630
556
|
providedIn: 'root',
|
|
631
557
|
}]
|
|
632
|
-
}], ctorParameters: function () { return [{ type: FronteggAppService }, { type: i1.Router }
|
|
558
|
+
}], ctorParameters: function () { return [{ type: FronteggAppService }, { type: i1.Router }]; } });
|
|
633
559
|
|
|
634
560
|
class FronteggAuthGuard extends FronteggBaseGuard {
|
|
635
561
|
constructor(fronteggAppService, fronteggAuthService, router, ngZone) {
|
|
@@ -812,9 +738,51 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImpo
|
|
|
812
738
|
* 3. Load entitlements on demand.
|
|
813
739
|
*/
|
|
814
740
|
class FronteggEntitlementsService {
|
|
815
|
-
constructor(fronteggAppService
|
|
741
|
+
constructor(fronteggAppService) {
|
|
816
742
|
this.fronteggAppService = fronteggAppService;
|
|
817
|
-
this.
|
|
743
|
+
this.userStateSubject = new BehaviorSubject(undefined);
|
|
744
|
+
const state = this.fronteggAppService.fronteggApp.store.getState();
|
|
745
|
+
this.updateUserStateIfNeeded(state.auth);
|
|
746
|
+
// Memoized entitlements State
|
|
747
|
+
this.fronteggAppService.fronteggApp.store.subscribe(() => {
|
|
748
|
+
const newState = this.fronteggAppService.fronteggApp.store.getState();
|
|
749
|
+
this.updateUserStateIfNeeded(newState.auth);
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Trigger entitlements subject change event if the entitlements reference changes
|
|
754
|
+
* No need for deep equal because we already check it internally
|
|
755
|
+
* @param authState
|
|
756
|
+
*/
|
|
757
|
+
updateUserStateIfNeeded(authState) {
|
|
758
|
+
const entitlementsState = authState.user;
|
|
759
|
+
if (this.userStateSubject.value === entitlementsState) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
this.userStateSubject.next(entitlementsState);
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* The function gives the ability to return a manipulated data of the user state as a subscription.
|
|
766
|
+
*
|
|
767
|
+
* @param dataManipulator Manipulator function that receives user state and returns a manipulated data
|
|
768
|
+
* @param observer For receiving manipulated data result
|
|
769
|
+
* @returns a subscription to be able to unsubscribe
|
|
770
|
+
*/
|
|
771
|
+
getUserManipulatorSubscription(dataManipulator, observer) {
|
|
772
|
+
// used for computing the entitlements result because we don't return the state itself, but a calculated one
|
|
773
|
+
const userSubject = new BehaviorSubject(undefined);
|
|
774
|
+
const stateSubscription = this.userStateSubject.subscribe(user => {
|
|
775
|
+
userSubject.next(dataManipulator(user));
|
|
776
|
+
});
|
|
777
|
+
// subscribing the consumer observer
|
|
778
|
+
const userResultSubscription = userSubject.asObservable().subscribe(observer);
|
|
779
|
+
// monkey patched to manage both un-subscriptions: state and user manipulated result
|
|
780
|
+
const originalUnsubscribe = userResultSubscription.unsubscribe.bind(userResultSubscription);
|
|
781
|
+
userResultSubscription.unsubscribe = () => {
|
|
782
|
+
originalUnsubscribe();
|
|
783
|
+
stateSubscription.unsubscribe();
|
|
784
|
+
};
|
|
785
|
+
return userResultSubscription;
|
|
818
786
|
}
|
|
819
787
|
/**
|
|
820
788
|
* @param feature
|
|
@@ -825,13 +793,7 @@ class FronteggEntitlementsService {
|
|
|
825
793
|
* @throws when entitlement is not enabled via frontegg options
|
|
826
794
|
*/
|
|
827
795
|
featureEntitlements$(feature, observer, customAttributes) {
|
|
828
|
-
return this.
|
|
829
|
-
// the entitlemenets-common npm doesn't know to overcome the case of signed out user, then we get console errors
|
|
830
|
-
if (user) {
|
|
831
|
-
return this.fronteggAppService.fronteggApp.getFeatureEntitlements(feature, customAttributes);
|
|
832
|
-
}
|
|
833
|
-
return { isEntitled: false, justification: NotEntitledJustification.MISSING_FEATURE };
|
|
834
|
-
}, observer);
|
|
796
|
+
return this.getUserManipulatorSubscription(() => { return this.fronteggAppService.fronteggApp.getFeatureEntitlements(feature, customAttributes); }, observer);
|
|
835
797
|
}
|
|
836
798
|
/**
|
|
837
799
|
* @param permission
|
|
@@ -841,12 +803,7 @@ class FronteggEntitlementsService {
|
|
|
841
803
|
* @returns a subscription to be able to unsubscribe
|
|
842
804
|
*/
|
|
843
805
|
permissionEntitlements$(permission, observer, customAttributes) {
|
|
844
|
-
return this.
|
|
845
|
-
if (user) {
|
|
846
|
-
return this.fronteggAppService.fronteggApp.getPermissionEntitlements(permission, customAttributes);
|
|
847
|
-
}
|
|
848
|
-
return { isEntitled: false, justification: NotEntitledJustification.MISSING_PERMISSION };
|
|
849
|
-
}, observer);
|
|
806
|
+
return this.getUserManipulatorSubscription(() => this.fronteggAppService.fronteggApp.getPermissionEntitlements(permission, customAttributes), observer);
|
|
850
807
|
}
|
|
851
808
|
/**
|
|
852
809
|
* @param options permissionKey or featureKey in an options object
|
|
@@ -856,13 +813,7 @@ class FronteggEntitlementsService {
|
|
|
856
813
|
* @returns a subscription to be able to unsubscribe
|
|
857
814
|
*/
|
|
858
815
|
entitlements$(options, observer, customAttributes) {
|
|
859
|
-
return this.
|
|
860
|
-
if (user) {
|
|
861
|
-
return this.fronteggAppService.fronteggApp.getEntitlements(options, customAttributes);
|
|
862
|
-
}
|
|
863
|
-
const justification = 'featureKey' in options ? NotEntitledJustification.MISSING_FEATURE : NotEntitledJustification.MISSING_PERMISSION;
|
|
864
|
-
return { isEntitled: false, justification };
|
|
865
|
-
}, observer);
|
|
816
|
+
return this.getUserManipulatorSubscription(() => this.fronteggAppService.fronteggApp.getEntitlements(options, customAttributes), observer);
|
|
866
817
|
}
|
|
867
818
|
/**
|
|
868
819
|
* Load entitlements data on demand
|
|
@@ -872,14 +823,14 @@ class FronteggEntitlementsService {
|
|
|
872
823
|
this.fronteggAppService.fronteggApp.loadEntitlements(callback);
|
|
873
824
|
}
|
|
874
825
|
}
|
|
875
|
-
FronteggEntitlementsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggEntitlementsService, deps: [{ token: FronteggAppService }
|
|
826
|
+
FronteggEntitlementsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggEntitlementsService, deps: [{ token: FronteggAppService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
876
827
|
FronteggEntitlementsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggEntitlementsService, providedIn: 'root' });
|
|
877
828
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FronteggEntitlementsService, decorators: [{
|
|
878
829
|
type: Injectable,
|
|
879
830
|
args: [{
|
|
880
831
|
providedIn: 'root',
|
|
881
832
|
}]
|
|
882
|
-
}], ctorParameters: function () { return [{ type: FronteggAppService }
|
|
833
|
+
}], ctorParameters: function () { return [{ type: FronteggAppService }]; } });
|
|
883
834
|
|
|
884
835
|
class FronteggAppModule {
|
|
885
836
|
static forRoot(config) {
|
|
@@ -892,7 +843,6 @@ class FronteggAppModule {
|
|
|
892
843
|
FronteggAuthService,
|
|
893
844
|
FronteggEntitlementsService,
|
|
894
845
|
FronteggSubscriptionService,
|
|
895
|
-
FronteggUserSubscriptionService,
|
|
896
846
|
{
|
|
897
847
|
provide: FronteggAppOptionsClass,
|
|
898
848
|
useValue: config,
|