@dsivd/prestations-ng 15.2.3-beta6 → 15.2.3-beta9

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.
@@ -32,36 +32,30 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
32
32
  /* eslint-disable @typescript-eslint/no-explicit-any */
33
33
  const IAM_SESSION_EXPIRED_HEADER = 'iam-session-expired';
34
34
  const CYBER_LOGIN_PATH = '/100018/login';
35
- const PORTAIL_IAM_ACV_EXTRA_PATH = 'portail.vd.ch:443/iamlogin';
36
- const PORTAIL_IAM_ACV_INTRA_PATH = 'portail.etat-de-vaud.ch:443/iamlogin';
37
- const isIamExpiredHeader = (event) => !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
38
- const isRedirectionToIamACV = (event) => {
39
- const isRedirection = event.status === 302 /* Found */;
40
- const location = event.headers.get('Location');
41
- return (isRedirection &&
42
- (location?.includes(PORTAIL_IAM_ACV_EXTRA_PATH) ||
43
- location?.includes(PORTAIL_IAM_ACV_INTRA_PATH)));
35
+ const ACV_LOGIN_PATH = '/iamlogin';
36
+ const isIamExpiredHeader = (event) => {
37
+ return !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
44
38
  };
45
- const isRedirectionToCyberLogin = (event) => {
39
+ const isRedirectionToLogin = (event) => {
46
40
  const isRedirection = event.status === 302 /* Found */;
47
- const location = event.headers.get('Location');
48
- return isRedirection && location?.includes(CYBER_LOGIN_PATH);
41
+ const locationHeader = event.headers.get('Location');
42
+ const isLocationCyberLogin = locationHeader?.includes(CYBER_LOGIN_PATH);
43
+ const isLocationAcvLogin = locationHeader?.includes(ACV_LOGIN_PATH);
44
+ return isRedirection && (isLocationCyberLogin || isLocationAcvLogin);
49
45
  };
50
46
  class IamExpiredInterceptorService {
51
47
  constructor() {
52
- this._iamExpirationHeaderPresence = new Subject();
48
+ this._isIamSessionExpired = new Subject();
53
49
  }
54
- get iamExpirationHeaderPresence() {
55
- return this._iamExpirationHeaderPresence.asObservable();
50
+ get isIamSessionExpired() {
51
+ return this._isIamSessionExpired.asObservable();
56
52
  }
57
53
  intercept(req, next) {
58
54
  return next.handle(req).pipe(map(event => {
59
- console.log('event', event);
60
55
  if (event instanceof HttpResponse) {
61
56
  if (isIamExpiredHeader(event) ||
62
- isRedirectionToIamACV(event) ||
63
- isRedirectionToCyberLogin(event)) {
64
- this._iamExpirationHeaderPresence.next(true);
57
+ isRedirectionToLogin(event)) {
58
+ this._isIamSessionExpired.next(true);
65
59
  }
66
60
  }
67
61
  return event;
@@ -69,11 +63,13 @@ class IamExpiredInterceptorService {
69
63
  }
70
64
  handleError(err) {
71
65
  if (err instanceof HttpErrorResponse) {
72
- if (err.status === 200) {
73
- const isLogin = err.url.indexOf(CYBER_LOGIN_PATH) > 0;
74
- if (isLogin) {
75
- this._iamExpirationHeaderPresence.next(true);
76
- }
66
+ // status is 200, but still an error since
67
+ // login page is returned when xml/json is expected
68
+ const isStatusOk = err.status === 200 /* Ok */;
69
+ const isUrlCyberLogin = err.url.includes(CYBER_LOGIN_PATH);
70
+ const isUrlAcvLogin = err.url.includes(ACV_LOGIN_PATH);
71
+ if (isStatusOk && (isUrlCyberLogin || isUrlAcvLogin)) {
72
+ this._isIamSessionExpired.next(true);
77
73
  }
78
74
  }
79
75
  return throwError(err);
@@ -9935,19 +9931,19 @@ class TableSort {
9935
9931
  class RedirectComponent {
9936
9932
  constructor(iamInterceptor) {
9937
9933
  this.iamInterceptor = iamInterceptor;
9938
- this.modalHeaderText = 'Information';
9939
- this.modalBodyText = `<p>Votre session a expiré.</p>
9940
- <p>Vous pouvez vous connecter à nouveau pour continuer à utiliser nos services.</p>`;
9941
- this.iamInterceptor.iamExpirationHeaderPresence
9934
+ this.iamInterceptor.isIamSessionExpired
9942
9935
  .pipe(first())
9943
9936
  .subscribe(() => this.showModal());
9944
9937
  }
9938
+ reloadPage() {
9939
+ window.location.reload();
9940
+ }
9945
9941
  showModal() {
9946
9942
  this.counter = 10;
9947
9943
  this.isModalVisible = true;
9948
9944
  setInterval(() => {
9949
9945
  if (0 === this.counter) {
9950
- window.location.reload();
9946
+ this.reloadPage();
9951
9947
  return;
9952
9948
  }
9953
9949
  this.counter--;
@@ -9955,10 +9951,10 @@ class RedirectComponent {
9955
9951
  }
9956
9952
  }
9957
9953
  RedirectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RedirectComponent, deps: [{ token: IamExpiredInterceptorService }], target: i0.ɵɵFactoryTarget.Component });
9958
- RedirectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.5", type: RedirectComponent, selector: "redirector", ngImport: i0, template: "<foehn-modal\n [modalBodyText]=\"modalBodyText\"\n [isModalVisible]=\"isModalVisible\"\n [modalHeaderText]=\"modalHeaderText\"\n [closeable]=\"false\"\n>\n <div modal-footer class=\"w-100 text-right font-weight-bold\">\n Vous allez \u00EAtre redirig\u00E9 dans {{ counter }} s.\n </div>\n</foehn-modal>\n", components: [{ type: FoehnModalComponent, selector: "foehn-modal", inputs: ["id", "name", "modalSize", "modalBodyText", "modalHeaderText", "closeable", "modalTriggerHtmlElement", "isModalVisible"], outputs: ["isModalVisibleChange"] }] });
9954
+ RedirectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.5", type: RedirectComponent, selector: "redirector", ngImport: i0, template: "<foehn-modal\n [modalHeaderText]=\"'Information'\"\n [isModalVisible]=\"isModalVisible\"\n [closeable]=\"false\"\n>\n <p>Votre session a expir\u00E9.</p>\n <p>Vous pouvez <a href=\"#\" (click)=\"$event.preventDefault(); reloadPage();\">vous connecter</a> \u00E0 nouveau pour continuer \u00E0 utiliser nos services.</p>\n\n <div modal-footer class=\"w-100 text-right font-weight-bold\">\n Vous allez \u00EAtre redirig\u00E9 dans {{ counter }} s.\n </div>\n</foehn-modal>\n", components: [{ type: FoehnModalComponent, selector: "foehn-modal", inputs: ["id", "name", "modalSize", "modalBodyText", "modalHeaderText", "closeable", "modalTriggerHtmlElement", "isModalVisible"], outputs: ["isModalVisibleChange"] }] });
9959
9955
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RedirectComponent, decorators: [{
9960
9956
  type: Component,
9961
- args: [{ selector: 'redirector', template: "<foehn-modal\n [modalBodyText]=\"modalBodyText\"\n [isModalVisible]=\"isModalVisible\"\n [modalHeaderText]=\"modalHeaderText\"\n [closeable]=\"false\"\n>\n <div modal-footer class=\"w-100 text-right font-weight-bold\">\n Vous allez \u00EAtre redirig\u00E9 dans {{ counter }} s.\n </div>\n</foehn-modal>\n" }]
9957
+ args: [{ selector: 'redirector', template: "<foehn-modal\n [modalHeaderText]=\"'Information'\"\n [isModalVisible]=\"isModalVisible\"\n [closeable]=\"false\"\n>\n <p>Votre session a expir\u00E9.</p>\n <p>Vous pouvez <a href=\"#\" (click)=\"$event.preventDefault(); reloadPage();\">vous connecter</a> \u00E0 nouveau pour continuer \u00E0 utiliser nos services.</p>\n\n <div modal-footer class=\"w-100 text-right font-weight-bold\">\n Vous allez \u00EAtre redirig\u00E9 dans {{ counter }} s.\n </div>\n</foehn-modal>\n" }]
9962
9958
  }], ctorParameters: function () { return [{ type: IamExpiredInterceptorService }]; } });
9963
9959
 
9964
9960
  class SdkRedirectModule {