osl-base-extended 12.6.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,14 +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));
417
+ getPublicIP() {
418
+ return this.plainHttp.get('https://api.ipify.org?format=json');
419
+ }
413
420
  // ─── Internals ────────────────────────────────────────────────────────────────
414
- getHeaders() {
421
+ async getHeaders() {
415
422
  const token = localStorage.getItem('token');
423
+ const userIp = await this.getCachedPublicIP();
416
424
  return new HttpHeaders({
417
425
  'Content-Type': 'application/json',
418
426
  Authorization: token ? `Bearer ${token}` : '',
427
+ 'ip-address': userIp
419
428
  });
420
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
+ }
421
443
  getUploadHeaders() {
422
444
  const token = localStorage.getItem('token');
423
445
  // No Content-Type — browser sets multipart boundary automatically
@@ -480,7 +502,7 @@ class Httpbase {
480
502
  const res = await firstValueFrom(this.http
481
503
  .post(this.getEndPoint(methodName), body, {
482
504
  observe: 'response',
483
- headers: this.getHeaders(),
505
+ headers: await this.getHeaders(),
484
506
  params: this.buildParams(params || []),
485
507
  })
486
508
  .pipe(timeout(30000)));
@@ -495,7 +517,7 @@ class Httpbase {
495
517
  const res = await firstValueFrom(this.http
496
518
  .get(this.getEndPoint(methodName), {
497
519
  observe: 'response',
498
- headers: this.getHeaders(),
520
+ headers: await this.getHeaders(),
499
521
  params: this.buildParams(params || []),
500
522
  })
501
523
  .pipe(timeout(30000)));
@@ -510,7 +532,7 @@ class Httpbase {
510
532
  const res = await firstValueFrom(this.http
511
533
  .put(this.getEndPoint(methodName), body, {
512
534
  observe: 'response',
513
- headers: this.getHeaders(),
535
+ headers: await this.getHeaders(),
514
536
  params: this.buildParams(params || []),
515
537
  })
516
538
  .pipe(timeout(30000)));
@@ -525,7 +547,7 @@ class Httpbase {
525
547
  const res = await firstValueFrom(this.http
526
548
  .patch(this.getEndPoint(methodName), body, {
527
549
  observe: 'response',
528
- headers: this.getHeaders(),
550
+ headers: await this.getHeaders(),
529
551
  })
530
552
  .pipe(timeout(30000)));
531
553
  return this.handleSuccess(res.status, res.body, res.headers);
@@ -539,7 +561,7 @@ class Httpbase {
539
561
  const res = await firstValueFrom(this.http
540
562
  .delete(this.getEndPoint(methodName), {
541
563
  observe: 'response',
542
- headers: this.getHeaders(),
564
+ headers: await this.getHeaders(),
543
565
  params: this.buildParams(params || []),
544
566
  })
545
567
  .pipe(timeout(30000)));
@@ -554,7 +576,7 @@ class Httpbase {
554
576
  const res = await firstValueFrom(this.http
555
577
  .get(this.getEndPoint(methodName), {
556
578
  observe: 'response',
557
- headers: this.getHeaders(),
579
+ headers: await this.getHeaders(),
558
580
  params: this.buildParams(params || []),
559
581
  responseType: 'blob',
560
582
  })