osl-base-extended 12.6.0 → 12.7.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.
@@ -410,12 +410,20 @@ class Httpbase {
410
410
  async getConfig() {
411
411
  return this.get('getConfig');
412
412
  }
413
+ getPublicIP() {
414
+ return this.http.get('https://api.ipify.org?format=json');
415
+ }
413
416
  // ─── Internals ────────────────────────────────────────────────────────────────
414
- getHeaders() {
417
+ async getHeaders() {
418
+ let userIp = "";
415
419
  const token = localStorage.getItem('token');
420
+ await this.getPublicIP().subscribe(res => {
421
+ userIp = res?.ip;
422
+ });
416
423
  return new HttpHeaders({
417
424
  'Content-Type': 'application/json',
418
425
  Authorization: token ? `Bearer ${token}` : '',
426
+ 'ip-address': userIp
419
427
  });
420
428
  }
421
429
  getUploadHeaders() {
@@ -480,7 +488,7 @@ class Httpbase {
480
488
  const res = await firstValueFrom(this.http
481
489
  .post(this.getEndPoint(methodName), body, {
482
490
  observe: 'response',
483
- headers: this.getHeaders(),
491
+ headers: await this.getHeaders(),
484
492
  params: this.buildParams(params || []),
485
493
  })
486
494
  .pipe(timeout(30000)));
@@ -495,7 +503,7 @@ class Httpbase {
495
503
  const res = await firstValueFrom(this.http
496
504
  .get(this.getEndPoint(methodName), {
497
505
  observe: 'response',
498
- headers: this.getHeaders(),
506
+ headers: await this.getHeaders(),
499
507
  params: this.buildParams(params || []),
500
508
  })
501
509
  .pipe(timeout(30000)));
@@ -510,7 +518,7 @@ class Httpbase {
510
518
  const res = await firstValueFrom(this.http
511
519
  .put(this.getEndPoint(methodName), body, {
512
520
  observe: 'response',
513
- headers: this.getHeaders(),
521
+ headers: await this.getHeaders(),
514
522
  params: this.buildParams(params || []),
515
523
  })
516
524
  .pipe(timeout(30000)));
@@ -525,7 +533,7 @@ class Httpbase {
525
533
  const res = await firstValueFrom(this.http
526
534
  .patch(this.getEndPoint(methodName), body, {
527
535
  observe: 'response',
528
- headers: this.getHeaders(),
536
+ headers: await this.getHeaders(),
529
537
  })
530
538
  .pipe(timeout(30000)));
531
539
  return this.handleSuccess(res.status, res.body, res.headers);
@@ -539,7 +547,7 @@ class Httpbase {
539
547
  const res = await firstValueFrom(this.http
540
548
  .delete(this.getEndPoint(methodName), {
541
549
  observe: 'response',
542
- headers: this.getHeaders(),
550
+ headers: await this.getHeaders(),
543
551
  params: this.buildParams(params || []),
544
552
  })
545
553
  .pipe(timeout(30000)));
@@ -554,7 +562,7 @@ class Httpbase {
554
562
  const res = await firstValueFrom(this.http
555
563
  .get(this.getEndPoint(methodName), {
556
564
  observe: 'response',
557
- headers: this.getHeaders(),
565
+ headers: await this.getHeaders(),
558
566
  params: this.buildParams(params || []),
559
567
  responseType: 'blob',
560
568
  })