@igo2/auth 1.9.3 → 1.11.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.
@@ -1157,7 +1157,7 @@
1157
1157
  return AuthInternComponent;
1158
1158
  }());
1159
1159
  AuthInternComponent.ɵfac = function AuthInternComponent_Factory(t) { return new (t || AuthInternComponent)(i0__namespace.ɵɵdirectiveInject(AuthService), i0__namespace.ɵɵdirectiveInject(i2__namespace.LanguageService), i0__namespace.ɵɵdirectiveInject(i3__namespace$2.FormBuilder)); };
1160
- AuthInternComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: AuthInternComponent, selectors: [["igo-auth-intern"]], inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, decls: 14, vars: 13, consts: [["role", "form", 3, "formGroup", "ngSubmit"], [1, "full-width"], ["matInput", "", "required", "", "formControlName", "username", 3, "placeholder"], ["matInput", "", "required", "", "type", "password", "formControlName", "password", 3, "placeholder"], ["mat-raised-button", "", "type", "submit", 3, "disabled"], ["mat-raised-button", "", "class", "anonymous", "type", "button", 3, "disabled", "click", 4, "ngIf"], [4, "ngIf"], ["mat-raised-button", "", "type", "button", 1, "anonymous", 3, "disabled", "click"], ["size", "3", "color", "red"]], template: function AuthInternComponent_Template(rf, ctx) {
1160
+ AuthInternComponent.ɵcmp = /*@__PURE__*/ i0__namespace.ɵɵdefineComponent({ type: AuthInternComponent, selectors: [["igo-auth-intern"]], inputs: { allowAnonymous: "allowAnonymous" }, outputs: { login: "login" }, decls: 14, vars: 12, consts: [["role", "form", 3, "formGroup", "ngSubmit"], [1, "full-width"], ["matInput", "", "required", "", "formControlName", "username", 3, "placeholder"], ["matInput", "", "required", "", "type", "password", "formControlName", "password", 3, "placeholder"], ["mat-raised-button", "", "type", "submit"], ["mat-raised-button", "", "class", "anonymous", "type", "button", 3, "disabled", "click", 4, "ngIf"], [4, "ngIf"], ["mat-raised-button", "", "type", "button", 1, "anonymous", 3, "disabled", "click"], ["size", "3", "color", "red"]], template: function AuthInternComponent_Template(rf, ctx) {
1161
1161
  if (rf & 1) {
1162
1162
  i0__namespace.ɵɵelementStart(0, "form", 0);
1163
1163
  i0__namespace.ɵɵlistener("ngSubmit", function AuthInternComponent_Template_form_ngSubmit_0_listener() { return ctx.loginUser(ctx.form.value); });
@@ -1184,13 +1184,11 @@
1184
1184
  if (rf & 2) {
1185
1185
  i0__namespace.ɵɵproperty("formGroup", ctx.form);
1186
1186
  i0__namespace.ɵɵadvance(3);
1187
- i0__namespace.ɵɵpropertyInterpolate("placeholder", i0__namespace.ɵɵpipeBind1(4, 7, "igo.auth.user"));
1187
+ i0__namespace.ɵɵpropertyInterpolate("placeholder", i0__namespace.ɵɵpipeBind1(4, 6, "igo.auth.user"));
1188
1188
  i0__namespace.ɵɵadvance(4);
1189
- i0__namespace.ɵɵpropertyInterpolate("placeholder", i0__namespace.ɵɵpipeBind1(8, 9, "igo.auth.password"));
1190
- i0__namespace.ɵɵadvance(2);
1191
- i0__namespace.ɵɵproperty("disabled", !ctx.form.valid || ctx.loading);
1192
- i0__namespace.ɵɵadvance(1);
1193
- i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(11, 11, "igo.auth.login"));
1189
+ i0__namespace.ɵɵpropertyInterpolate("placeholder", i0__namespace.ɵɵpipeBind1(8, 8, "igo.auth.password"));
1190
+ i0__namespace.ɵɵadvance(3);
1191
+ i0__namespace.ɵɵtextInterpolate(i0__namespace.ɵɵpipeBind1(11, 10, "igo.auth.login"));
1194
1192
  i0__namespace.ɵɵadvance(2);
1195
1193
  i0__namespace.ɵɵproperty("ngIf", ctx.allowAnonymous);
1196
1194
  i0__namespace.ɵɵadvance(1);
@@ -1695,9 +1693,22 @@
1695
1693
  enumerable: false,
1696
1694
  configurable: true
1697
1695
  });
1696
+ Object.defineProperty(AuthInterceptor.prototype, "hostsWithAuthByKey", {
1697
+ get: function () {
1698
+ return this.config.getConfig('auth.hostsByKey') || [];
1699
+ },
1700
+ enumerable: false,
1701
+ configurable: true
1702
+ });
1698
1703
  AuthInterceptor.prototype.intercept = function (originalReq, next) {
1699
1704
  var withCredentials = this.handleHostsWithCredentials(originalReq.url);
1700
1705
  var req = originalReq.clone();
1706
+ var hostWithKey = this.handleHostsAuthByKey(originalReq.url);
1707
+ if (hostWithKey) {
1708
+ req = req.clone({
1709
+ params: req.params.set(hostWithKey.key, hostWithKey.value)
1710
+ });
1711
+ }
1701
1712
  if (withCredentials) {
1702
1713
  req = originalReq.clone({
1703
1714
  withCredentials: withCredentials
@@ -1750,6 +1761,21 @@
1750
1761
  xhr.setRequestHeader('Authorization', 'Bearer ' + token);
1751
1762
  return true;
1752
1763
  };
1764
+ AuthInterceptor.prototype.alterUrlWithKeyAuth = function (url) {
1765
+ var hostWithKey = this.handleHostsAuthByKey(url);
1766
+ var interceptedUrl = url;
1767
+ if (hostWithKey) {
1768
+ var urlDecomposed = interceptedUrl.split(/[?&]/);
1769
+ var urlWithKeyAdded = urlDecomposed.shift();
1770
+ var paramsToKeep = urlDecomposed.filter(function (p) { return p.length !== 0; });
1771
+ paramsToKeep.push(hostWithKey.key + "=" + hostWithKey.value);
1772
+ if (paramsToKeep.length) {
1773
+ urlWithKeyAdded += '?' + paramsToKeep.join('&');
1774
+ }
1775
+ return urlWithKeyAdded;
1776
+ }
1777
+ return;
1778
+ };
1753
1779
  AuthInterceptor.prototype.handleHostsWithCredentials = function (reqUrl) {
1754
1780
  var e_1, _a;
1755
1781
  var withCredentials = false;
@@ -1772,6 +1798,32 @@
1772
1798
  }
1773
1799
  return withCredentials;
1774
1800
  };
1801
+ AuthInterceptor.prototype.handleHostsAuthByKey = function (reqUrl) {
1802
+ var e_2, _a;
1803
+ var hostWithKey;
1804
+ try {
1805
+ for (var _b = __values(this.hostsWithAuthByKey), _c = _b.next(); !_c.done; _c = _b.next()) {
1806
+ var hostWithAuthByKey = _c.value;
1807
+ var domainRegex = new RegExp(hostWithAuthByKey.domainRegFilters);
1808
+ if (domainRegex.test(reqUrl)) {
1809
+ var replace = hostWithAuthByKey.keyProperty + "=" + hostWithAuthByKey.keyValue;
1810
+ var keyAdded = new RegExp(replace, "gm");
1811
+ if (!keyAdded.test(reqUrl)) {
1812
+ hostWithKey = { key: hostWithAuthByKey.keyProperty, value: hostWithAuthByKey.keyValue };
1813
+ break;
1814
+ }
1815
+ }
1816
+ }
1817
+ }
1818
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1819
+ finally {
1820
+ try {
1821
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1822
+ }
1823
+ finally { if (e_2) throw e_2.error; }
1824
+ }
1825
+ return hostWithKey;
1826
+ };
1775
1827
  AuthInterceptor.prototype.refreshToken = function () {
1776
1828
  var _this = this;
1777
1829
  var jwt = this.tokenService.decode();