@frontegg/angular 4.20.0-alpha.2898017504 → 4.20.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/bundles/frontegg-angular.umd.js +78 -39
- package/bundles/frontegg-angular.umd.js.map +1 -1
- package/bundles/frontegg-angular.umd.min.js +1 -1
- package/bundles/frontegg-angular.umd.min.js.map +1 -1
- package/esm2015/lib/frontegg-app.service.js +22 -15
- package/esm2015/lib/frontegg-auth.service.js +45 -15
- package/fesm2015/frontegg-angular.js +63 -28
- package/fesm2015/frontegg-angular.js.map +1 -1
- package/frontegg-angular.metadata.json +1 -1
- package/lib/frontegg-app.service.d.ts +2 -1
- package/lib/frontegg-app.service.d.ts.map +1 -1
- package/lib/frontegg-auth.service.d.ts +7 -1
- package/lib/frontegg-auth.service.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -395,7 +395,10 @@
|
|
|
395
395
|
this.isLoadingSubject = new rxjs.BehaviorSubject(true);
|
|
396
396
|
this.isAuthenticatedSubject = new rxjs.BehaviorSubject(false);
|
|
397
397
|
this.stateSubject = new rxjs.BehaviorSubject({});
|
|
398
|
-
this.authStateSubject = new rxjs.BehaviorSubject({
|
|
398
|
+
this.authStateSubject = new rxjs.BehaviorSubject({
|
|
399
|
+
isLoading: true,
|
|
400
|
+
isAuthenticated: false,
|
|
401
|
+
});
|
|
399
402
|
this.auditsStateSubject = new rxjs.BehaviorSubject({});
|
|
400
403
|
this.connectivityStateSubject = new rxjs.BehaviorSubject({});
|
|
401
404
|
this.subscriptionsStateSubject = new rxjs.BehaviorSubject({});
|
|
@@ -436,21 +439,11 @@
|
|
|
436
439
|
children: __spreadArray([], __read(this.router.config)),
|
|
437
440
|
},
|
|
438
441
|
]));
|
|
442
|
+
var initialFronteggState = this.fronteggApp.store.getState();
|
|
443
|
+
this.updateState(initialFronteggState);
|
|
439
444
|
// Subscribe on fronteggApp store to change state subjects
|
|
440
445
|
this.fronteggApp.store.subscribe(function () {
|
|
441
|
-
|
|
442
|
-
if (_this.isLoadingSubject.getValue() !== fronteggStore.auth.isLoading) {
|
|
443
|
-
_this.isLoadingSubject.next(fronteggStore.auth.isLoading);
|
|
444
|
-
}
|
|
445
|
-
if (_this.isAuthenticatedSubject.getValue() !== fronteggStore.auth.isAuthenticated) {
|
|
446
|
-
_this.isAuthenticatedSubject.next(fronteggStore.auth.isAuthenticated);
|
|
447
|
-
}
|
|
448
|
-
_this.stateSubject.next(fronteggStore);
|
|
449
|
-
_this.authStateSubject.next(fronteggStore.auth);
|
|
450
|
-
_this.auditsStateSubject.next(fronteggStore.audits);
|
|
451
|
-
_this.connectivityStateSubject.next(fronteggStore.connectivity);
|
|
452
|
-
_this.subscriptionsStateSubject.next(fronteggStore.subscriptions);
|
|
453
|
-
_this.vendorStateSubject.next(fronteggStore.vendor);
|
|
446
|
+
_this.updateState(_this.fronteggApp.store.getState());
|
|
454
447
|
});
|
|
455
448
|
}
|
|
456
449
|
Object.defineProperty(FronteggAppService.prototype, "state$", {
|
|
@@ -511,6 +504,20 @@
|
|
|
511
504
|
configurable: true
|
|
512
505
|
});
|
|
513
506
|
;
|
|
507
|
+
FronteggAppService.prototype.updateState = function (fronteggStore) {
|
|
508
|
+
if (this.isLoadingSubject.getValue() !== fronteggStore.auth.isLoading) {
|
|
509
|
+
this.isLoadingSubject.next(fronteggStore.auth.isLoading);
|
|
510
|
+
}
|
|
511
|
+
if (this.isAuthenticatedSubject.getValue() !== fronteggStore.auth.isAuthenticated) {
|
|
512
|
+
this.isAuthenticatedSubject.next(fronteggStore.auth.isAuthenticated);
|
|
513
|
+
}
|
|
514
|
+
this.stateSubject.next(fronteggStore);
|
|
515
|
+
this.authStateSubject.next(fronteggStore.auth);
|
|
516
|
+
this.auditsStateSubject.next(fronteggStore.audits);
|
|
517
|
+
this.connectivityStateSubject.next(fronteggStore.connectivity);
|
|
518
|
+
this.subscriptionsStateSubject.next(fronteggStore.subscriptions);
|
|
519
|
+
this.vendorStateSubject.next(fronteggStore.vendor);
|
|
520
|
+
};
|
|
514
521
|
Object.defineProperty(FronteggAppService.prototype, "mapAuthComponents", {
|
|
515
522
|
get: function () {
|
|
516
523
|
var authRoutes = this.authRoutes;
|
|
@@ -638,9 +645,11 @@
|
|
|
638
645
|
]; };
|
|
639
646
|
|
|
640
647
|
var FronteggAuthService = /** @class */ (function () {
|
|
641
|
-
function FronteggAuthService(fronteggAppService) {
|
|
648
|
+
function FronteggAuthService(fronteggAppService, router) {
|
|
642
649
|
var _this = this;
|
|
643
650
|
this.fronteggAppService = fronteggAppService;
|
|
651
|
+
this.router = router;
|
|
652
|
+
this.authStateSubject = new rxjs.BehaviorSubject({ isAuthenticated: false, isLoading: true });
|
|
644
653
|
this.acceptInvitationStateSubject = new rxjs.BehaviorSubject({});
|
|
645
654
|
this.accountSettingsStateSubject = new rxjs.BehaviorSubject({});
|
|
646
655
|
this.activateStateSubject = new rxjs.BehaviorSubject({});
|
|
@@ -670,7 +679,13 @@
|
|
|
670
679
|
this.setLoginState = function (state) { return _this.dispatchAction('setLoginState', state); };
|
|
671
680
|
this.resetLoginState = function () { return _this.dispatchAction('resetLoginState'); };
|
|
672
681
|
this.requestAuthorize = function (firstTime) { return _this.dispatchAction('requestAuthorize', firstTime); };
|
|
673
|
-
this.loginWithRedirect = function () {
|
|
682
|
+
this.loginWithRedirect = function () {
|
|
683
|
+
if (_this.isHostedLoginCallbackRoute()) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
_this.dispatchAction('requestHostedLoginAuthorize');
|
|
687
|
+
_this.setState({ isLoading: true });
|
|
688
|
+
};
|
|
674
689
|
this.preLogin = function (payload) { return _this.dispatchAction('preLogin', payload); };
|
|
675
690
|
this.postLogin = function (payload) { return _this.dispatchAction('postLogin', payload); };
|
|
676
691
|
this.login = function (payload) { return _this.dispatchAction('login', payload); };
|
|
@@ -820,30 +835,21 @@
|
|
|
820
835
|
{ field: 'isSSOAuth', subject: this.isSSOAuthSubject },
|
|
821
836
|
{ field: 'ssoACS', subject: this.ssoACSSubject },
|
|
822
837
|
];
|
|
838
|
+
var state = this.fronteggAppService.fronteggApp.store.getState();
|
|
839
|
+
this.updateState(state.auth, authSubStates);
|
|
823
840
|
// Memoized Auth State
|
|
824
|
-
this.fronteggAppService.
|
|
825
|
-
var
|
|
826
|
-
|
|
827
|
-
try {
|
|
828
|
-
for (var authSubStates_1 = __values(authSubStates), authSubStates_1_1 = authSubStates_1.next(); !authSubStates_1_1.done; authSubStates_1_1 = authSubStates_1.next()) {
|
|
829
|
-
var authSubState = authSubStates_1_1.value;
|
|
830
|
-
if (!FastDeepEqual__default['default'](authSubState.subject.getValue(), authState[authSubState.field])) {
|
|
831
|
-
authSubState.subject.next(authState[authSubState.field]);
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
836
|
-
finally {
|
|
837
|
-
try {
|
|
838
|
-
if (authSubStates_1_1 && !authSubStates_1_1.done && (_a = authSubStates_1.return)) _a.call(authSubStates_1);
|
|
839
|
-
}
|
|
840
|
-
finally { if (e_1) throw e_1.error; }
|
|
841
|
-
}
|
|
842
|
-
_this.isAuthenticatedSubject.next(authState.isAuthenticated);
|
|
843
|
-
_this.isLoadingSubject.next(authState.isLoading);
|
|
844
|
-
}
|
|
841
|
+
this.fronteggAppService.fronteggApp.store.subscribe(function () {
|
|
842
|
+
var newState = _this.fronteggAppService.fronteggApp.store.getState();
|
|
843
|
+
_this.updateState(newState.auth, authSubStates);
|
|
845
844
|
});
|
|
846
845
|
}
|
|
846
|
+
Object.defineProperty(FronteggAuthService.prototype, "authState$", {
|
|
847
|
+
get: function () {
|
|
848
|
+
return this.authStateSubject.asObservable();
|
|
849
|
+
},
|
|
850
|
+
enumerable: false,
|
|
851
|
+
configurable: true
|
|
852
|
+
});
|
|
847
853
|
Object.defineProperty(FronteggAuthService.prototype, "acceptInvitationState$", {
|
|
848
854
|
get: function () {
|
|
849
855
|
return this.acceptInvitationStateSubject.asObservable();
|
|
@@ -1005,21 +1011,54 @@
|
|
|
1005
1011
|
enumerable: false,
|
|
1006
1012
|
configurable: true
|
|
1007
1013
|
});
|
|
1014
|
+
FronteggAuthService.prototype.updateState = function (authState, authSubStates) {
|
|
1015
|
+
var e_1, _a;
|
|
1016
|
+
if (this.authStateSubject.value !== authState) {
|
|
1017
|
+
this.authStateSubject.next(authState);
|
|
1018
|
+
}
|
|
1019
|
+
try {
|
|
1020
|
+
for (var authSubStates_1 = __values(authSubStates), authSubStates_1_1 = authSubStates_1.next(); !authSubStates_1_1.done; authSubStates_1_1 = authSubStates_1.next()) {
|
|
1021
|
+
var authSubState = authSubStates_1_1.value;
|
|
1022
|
+
if (!FastDeepEqual__default['default'](authSubState.subject.value, authState[authSubState.field])) {
|
|
1023
|
+
authSubState.subject.next(authState[authSubState.field]);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1028
|
+
finally {
|
|
1029
|
+
try {
|
|
1030
|
+
if (authSubStates_1_1 && !authSubStates_1_1.done && (_a = authSubStates_1.return)) _a.call(authSubStates_1);
|
|
1031
|
+
}
|
|
1032
|
+
finally { if (e_1) throw e_1.error; }
|
|
1033
|
+
}
|
|
1034
|
+
if (this.isAuthenticatedSubject.value !== authState.isAuthenticated) {
|
|
1035
|
+
this.isAuthenticatedSubject.next(authState.isAuthenticated);
|
|
1036
|
+
}
|
|
1037
|
+
if (this.isLoadingSubject.value !== authState.isLoading) {
|
|
1038
|
+
this.isLoadingSubject.next(authState.isLoading);
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1008
1041
|
FronteggAuthService.prototype.dispatchAction = function (type, payload) {
|
|
1009
1042
|
var store = this.fronteggAppService.fronteggApp.store;
|
|
1010
1043
|
// @ts-ignore
|
|
1011
1044
|
store.dispatch({ type: reduxStore.authStoreName + "/" + type, payload: payload });
|
|
1012
1045
|
};
|
|
1046
|
+
FronteggAuthService.prototype.isHostedLoginCallbackRoute = function () {
|
|
1047
|
+
var path = this.fronteggAppService.router.url;
|
|
1048
|
+
var hostedLoginRedirectUrl = this.fronteggAppService.authRoutes.hostedLoginRedirectUrl;
|
|
1049
|
+
return path.startsWith(hostedLoginRedirectUrl !== null && hostedLoginRedirectUrl !== void 0 ? hostedLoginRedirectUrl : '/oauth/callback');
|
|
1050
|
+
};
|
|
1013
1051
|
return FronteggAuthService;
|
|
1014
1052
|
}());
|
|
1015
|
-
FronteggAuthService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FronteggAuthService_Factory() { return new FronteggAuthService(i0__namespace.ɵɵinject(FronteggAppService)); }, token: FronteggAuthService, providedIn: "root" });
|
|
1053
|
+
FronteggAuthService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function FronteggAuthService_Factory() { return new FronteggAuthService(i0__namespace.ɵɵinject(FronteggAppService), i0__namespace.ɵɵinject(i1__namespace.Router)); }, token: FronteggAuthService, providedIn: "root" });
|
|
1016
1054
|
FronteggAuthService.decorators = [
|
|
1017
1055
|
{ type: i0.Injectable, args: [{
|
|
1018
1056
|
providedIn: 'root',
|
|
1019
1057
|
},] }
|
|
1020
1058
|
];
|
|
1021
1059
|
FronteggAuthService.ctorParameters = function () { return [
|
|
1022
|
-
{ type: FronteggAppService }
|
|
1060
|
+
{ type: FronteggAppService },
|
|
1061
|
+
{ type: i1.Router }
|
|
1023
1062
|
]; };
|
|
1024
1063
|
|
|
1025
1064
|
var AuthorizedContentDirective = /** @class */ (function () {
|