osl-base-extended 12.7.0 → 12.8.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.
@@ -12,7 +12,7 @@ import * as i3 from '@angular/material/icon';
12
12
  import { MatIconModule } from '@angular/material/icon';
13
13
  import * as i3$1 from '@angular/cdk/drag-drop';
14
14
  import { DragDropModule, moveItemInArray } from '@angular/cdk/drag-drop';
15
- import { HttpHeaders, HttpParams, HttpClient } from '@angular/common/http';
15
+ import { HttpClient, HttpBackend, HttpHeaders, HttpParams } from '@angular/common/http';
16
16
  import { firstValueFrom, timeout, BehaviorSubject, debounceTime, distinctUntilChanged, from, of } from 'rxjs';
17
17
  import * as i1$2 from '@angular/forms';
18
18
  import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
@@ -410,22 +410,36 @@ class Httpbase {
410
410
  async getConfig() {
411
411
  return this.get('getConfig');
412
412
  }
413
+ // Bare HttpClient bypassing app-registered interceptors — ipify.org only
414
+ // supports plain, unauthenticated CORS requests, so any interceptor that
415
+ // attaches Authorization/credentials to every request would break this call.
416
+ plainHttp = new HttpClient(inject(HttpBackend));
413
417
  getPublicIP() {
414
- return this.http.get('https://api.ipify.org?format=json');
418
+ return this.plainHttp.get('https://api.ipify.org?format=json');
415
419
  }
416
420
  // ─── Internals ────────────────────────────────────────────────────────────────
417
421
  async getHeaders() {
418
- let userIp = "";
419
422
  const token = localStorage.getItem('token');
420
- await this.getPublicIP().subscribe(res => {
421
- userIp = res?.ip;
422
- });
423
+ const userIp = await this.getCachedPublicIP();
423
424
  return new HttpHeaders({
424
425
  'Content-Type': 'application/json',
425
426
  Authorization: token ? `Bearer ${token}` : '',
426
427
  'ip-address': userIp
427
428
  });
428
429
  }
430
+ cachedIp = null;
431
+ async getCachedPublicIP() {
432
+ if (this.cachedIp)
433
+ return this.cachedIp;
434
+ try {
435
+ const res = await firstValueFrom(this.getPublicIP());
436
+ this.cachedIp = res?.ip ?? '';
437
+ }
438
+ catch {
439
+ this.cachedIp = '';
440
+ }
441
+ return this.cachedIp;
442
+ }
429
443
  getUploadHeaders() {
430
444
  const token = localStorage.getItem('token');
431
445
  // No Content-Type — browser sets multipart boundary automatically