@frontegg/angular 6.9.0 → 6.10.0-alpha.6962449603
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 +75 -34
- package/bundles/frontegg-angular.umd.js.map +1 -1
- package/esm2015/lib/frontegg-app.service.js +6 -5
- package/esm2015/lib/frontegg-auth.service.js +6 -3
- package/esm2015/lib/frontegg.utils.js +10 -0
- package/esm2015/lib/guards/frontegg-auth.guard.js +45 -28
- package/fesm2015/frontegg-angular.js +61 -32
- package/fesm2015/frontegg-angular.js.map +1 -1
- package/lib/frontegg-app.service.d.ts.map +1 -1
- package/lib/frontegg-auth.service.d.ts +2 -1
- package/lib/frontegg-auth.service.d.ts.map +1 -1
- package/lib/frontegg.utils.d.ts +3 -0
- package/lib/frontegg.utils.d.ts.map +1 -0
- package/lib/guards/frontegg-auth.guard.d.ts +10 -1
- package/lib/guards/frontegg-auth.guard.d.ts.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -485
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@frontegg/js'), require('@frontegg/redux-store'), require('rxjs'), require('@frontegg/rest-api'), require('@angular/core/package.json'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@frontegg/angular', ['exports', '@angular/core', '@angular/common', '@angular/router', '@frontegg/js', '@frontegg/redux-store', 'rxjs', '@frontegg/rest-api', '@angular/core/package.json', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.frontegg = global.frontegg || {}, global.frontegg.angular = {}), global.ng.core, global.ng.common, global.ng.router, global.FronteggJS, global.FronteggReduxStore, global.rxjs, global.FronteggRestApi, global.ng.core.packageJson, global.
|
|
5
|
-
})(this, (function (exports, i0, common, i1, js, reduxStore, rxjs, restApi, angularCoreVersion,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@frontegg/js'), require('@frontegg/redux-store'), require('rxjs'), require('@frontegg/rest-api'), require('@angular/core/package.json'), require('fast-deep-equal')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@frontegg/angular', ['exports', '@angular/core', '@angular/common', '@angular/router', '@frontegg/js', '@frontegg/redux-store', 'rxjs', '@frontegg/rest-api', '@angular/core/package.json', 'fast-deep-equal'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.frontegg = global.frontegg || {}, global.frontegg.angular = {}), global.ng.core, global.ng.common, global.ng.router, global.FronteggJS, global.FronteggReduxStore, global.rxjs, global.FronteggRestApi, global.ng.core.packageJson, global.FastDeepEqual));
|
|
5
|
+
})(this, (function (exports, i0, common, i1, js, reduxStore, rxjs, restApi, angularCoreVersion, FastDeepEqual) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -415,13 +415,14 @@
|
|
|
415
415
|
});
|
|
416
416
|
}
|
|
417
417
|
};
|
|
418
|
-
var
|
|
419
|
-
contextOptions.metadataHeaders = {
|
|
418
|
+
var metadataHeaders = {
|
|
420
419
|
fronteggSdkVersion: "@frontegg/angular@" + sdkVersion.version,
|
|
421
|
-
//TODO: remove this
|
|
422
|
-
|
|
420
|
+
// TODO: remove this any type after updating rest-api context options type to accept string.
|
|
421
|
+
// @ts-ignore
|
|
423
422
|
framework: restApi.FronteggFrameworks.Angular + "@" + angularCoreVersion__default["default"].version,
|
|
424
423
|
};
|
|
424
|
+
// prepare config default values
|
|
425
|
+
this.config = Object.assign(Object.assign({}, this.config), { contextOptions: Object.assign(Object.assign({}, this.config.contextOptions), { metadataHeaders: metadataHeaders }), authOptions: Object.assign(Object.assign({}, this.config.authOptions), { hostedLoginOptions: Object.assign({ loadUserOnFirstLoad: true }, (_a = this.config.authOptions) === null || _a === void 0 ? void 0 : _a.hostedLoginOptions), onRedirectTo: onRedirectTo }) });
|
|
425
426
|
restApi.ContextHolder.setOnRedirectTo(onRedirectTo);
|
|
426
427
|
this.fronteggApp = js.initialize(Object.assign({ onRedirectTo: onRedirectTo }, this.config));
|
|
427
428
|
// Add all login box routes to Angular router config
|
|
@@ -614,6 +615,15 @@
|
|
|
614
615
|
return FronteggBaseGuard;
|
|
615
616
|
}());
|
|
616
617
|
|
|
618
|
+
var runNgZoneIfNeeded = function (ngZone, fn) {
|
|
619
|
+
if (i0.NgZone.isInAngularZone()) {
|
|
620
|
+
fn();
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
ngZone.run(fn);
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
|
|
617
627
|
var FronteggAuthService = /** @class */ (function () {
|
|
618
628
|
function FronteggAuthService(fronteggAppService, router) {
|
|
619
629
|
var _this = this;
|
|
@@ -649,11 +659,13 @@
|
|
|
649
659
|
this.setLoginState = function (state) { return _this.dispatchAction('setLoginState', state); };
|
|
650
660
|
this.resetLoginState = function () { return _this.dispatchAction('resetLoginState'); };
|
|
651
661
|
this.requestAuthorize = function (firstTime) { return _this.dispatchAction('requestAuthorize', firstTime); };
|
|
652
|
-
this.loginWithRedirect = function (params) {
|
|
662
|
+
this.loginWithRedirect = function (params, shouldRedirectToLogin, firstTime) {
|
|
663
|
+
if (shouldRedirectToLogin === void 0) { shouldRedirectToLogin = true; }
|
|
664
|
+
if (firstTime === void 0) { firstTime = false; }
|
|
653
665
|
if (_this.isHostedLoginCallbackRoute()) {
|
|
654
666
|
return;
|
|
655
667
|
}
|
|
656
|
-
_this.dispatchAction('
|
|
668
|
+
_this.dispatchAction('requestHostedLoginAuthorizeV2', { additionalParams: params, shouldRedirectToLogin: shouldRedirectToLogin, firstTime: firstTime });
|
|
657
669
|
_this.setState({ isLoading: true });
|
|
658
670
|
};
|
|
659
671
|
this.preLogin = function (payload) { return _this.dispatchAction('preLogin', payload); };
|
|
@@ -813,6 +825,9 @@
|
|
|
813
825
|
_this.updateState(newState.auth, authSubStates);
|
|
814
826
|
});
|
|
815
827
|
}
|
|
828
|
+
FronteggAuthService.prototype.getAuthState = function () {
|
|
829
|
+
return this.fronteggAppService.fronteggApp.store.getState().auth;
|
|
830
|
+
};
|
|
816
831
|
Object.defineProperty(FronteggAuthService.prototype, "authState$", {
|
|
817
832
|
get: function () {
|
|
818
833
|
return this.authStateSubject.asObservable();
|
|
@@ -1039,42 +1054,68 @@
|
|
|
1039
1054
|
_this.ngZone = ngZone;
|
|
1040
1055
|
return _this;
|
|
1041
1056
|
}
|
|
1042
|
-
|
|
1057
|
+
/**
|
|
1058
|
+
* Wait for loader to finish
|
|
1059
|
+
* @private
|
|
1060
|
+
*/
|
|
1061
|
+
FronteggAuthGuard.prototype.waitForLoader = function () {
|
|
1062
|
+
var _this = this;
|
|
1063
|
+
return new Promise(function (resolve) {
|
|
1064
|
+
var subscription = _this.fronteggAppService.isLoading$.subscribe(function (isLoading) {
|
|
1065
|
+
if (!isLoading) {
|
|
1066
|
+
resolve(true);
|
|
1067
|
+
subscription.unsubscribe();
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
});
|
|
1071
|
+
};
|
|
1072
|
+
/**
|
|
1073
|
+
* Navigate to login page if user is not authenticated
|
|
1074
|
+
* @private
|
|
1075
|
+
*/
|
|
1076
|
+
FronteggAuthGuard.prototype.navigateToLoginIfNeeded = function (redirectUrl) {
|
|
1043
1077
|
return __awaiter(this, void 0, void 0, function () {
|
|
1078
|
+
var isAuthenticated;
|
|
1044
1079
|
return __generator(this, function (_a) {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
this.
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1080
|
+
isAuthenticated = this.fronteggAuthService.getAuthState().isAuthenticated;
|
|
1081
|
+
if (!isAuthenticated) {
|
|
1082
|
+
if (this.fronteggAppService.fronteggApp.options.hostedLoginBox) {
|
|
1083
|
+
localStorage.setItem('FRONTEGG_AFTER_AUTH_REDIRECT_URL', redirectUrl);
|
|
1084
|
+
this.fronteggAuthService.loginWithRedirect({ prompt: 'login' });
|
|
1085
|
+
return [2 /*return*/, false];
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
return [2 /*return*/, this.router.navigateByUrl(this.fronteggAppService.authRoutes.loginUrl + '?redirectUrl=' + encodeURIComponent(redirectUrl))];
|
|
1089
|
+
}
|
|
1052
1090
|
}
|
|
1053
|
-
return [2 /*return
|
|
1091
|
+
return [2 /*return*/, true]; // activate navigation
|
|
1054
1092
|
});
|
|
1055
1093
|
});
|
|
1056
1094
|
};
|
|
1057
1095
|
FronteggAuthGuard.prototype.canActivate = function (route, state) {
|
|
1058
1096
|
var _this = this;
|
|
1059
1097
|
var redirectUrl = state.url;
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1098
|
+
var isLoading = this.fronteggAuthService.getAuthState().isLoading;
|
|
1099
|
+
if (!isLoading) {
|
|
1100
|
+
// if showLoader false
|
|
1101
|
+
// check if user is authenticated
|
|
1102
|
+
return this.navigateToLoginIfNeeded(redirectUrl);
|
|
1103
|
+
}
|
|
1104
|
+
// wait for loader to finish and then check if user is authenticated
|
|
1105
|
+
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
1106
|
+
var _this = this;
|
|
1107
|
+
return __generator(this, function (_a) {
|
|
1108
|
+
switch (_a.label) {
|
|
1109
|
+
case 0: return [4 /*yield*/, this.waitForLoader()];
|
|
1110
|
+
case 1:
|
|
1111
|
+
_a.sent();
|
|
1112
|
+
runNgZoneIfNeeded(this.ngZone, function () {
|
|
1113
|
+
_this.navigateToLoginIfNeeded(redirectUrl).then(resolve).catch(reject);
|
|
1072
1114
|
});
|
|
1073
|
-
|
|
1115
|
+
return [2 /*return*/];
|
|
1074
1116
|
}
|
|
1075
1117
|
});
|
|
1076
|
-
|
|
1077
|
-
});
|
|
1118
|
+
}); });
|
|
1078
1119
|
};
|
|
1079
1120
|
return FronteggAuthGuard;
|
|
1080
1121
|
}(FronteggBaseGuard));
|