osl-base-extended 12.7.0 → 12.9.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
|
|
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';
|
|
@@ -369,6 +369,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
369
369
|
args: ['window:beforeunload', ['$event']]
|
|
370
370
|
}] } });
|
|
371
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Controls whether Httpbase attaches the caller's public IP (via ipify.org)
|
|
374
|
+
* as the `ip-address` header on every outgoing request. Defaults to false
|
|
375
|
+
* when not provided, so existing projects are unaffected until they opt in.
|
|
376
|
+
*/
|
|
377
|
+
const OSL_ATTACH_CALLER_IP = new InjectionToken('OSL_ATTACH_CALLER_IP');
|
|
378
|
+
/** Opt in from app.config.ts: providers: [provideCallerIpHeader()] */
|
|
379
|
+
function provideCallerIpHeader(enabled = true) {
|
|
380
|
+
return { provide: OSL_ATTACH_CALLER_IP, useValue: enabled };
|
|
381
|
+
}
|
|
382
|
+
|
|
372
383
|
class Httpbase {
|
|
373
384
|
controller;
|
|
374
385
|
baseUrl;
|
|
@@ -410,21 +421,40 @@ class Httpbase {
|
|
|
410
421
|
async getConfig() {
|
|
411
422
|
return this.get('getConfig');
|
|
412
423
|
}
|
|
424
|
+
// Bare HttpClient bypassing app-registered interceptors — ipify.org only
|
|
425
|
+
// supports plain, unauthenticated CORS requests, so any interceptor that
|
|
426
|
+
// attaches Authorization/credentials to every request would break this call.
|
|
427
|
+
plainHttp = new HttpClient(inject(HttpBackend));
|
|
428
|
+
// Opt-in via provideCallerIpHeader() in app.config.ts; defaults to off so
|
|
429
|
+
// existing consumers of this library are unaffected until they enable it.
|
|
430
|
+
attachCallerIp = inject(OSL_ATTACH_CALLER_IP, { optional: true }) ?? false;
|
|
413
431
|
getPublicIP() {
|
|
414
|
-
return this.
|
|
432
|
+
return this.plainHttp.get('https://api.ipify.org?format=json');
|
|
415
433
|
}
|
|
416
434
|
// ─── Internals ────────────────────────────────────────────────────────────────
|
|
417
435
|
async getHeaders() {
|
|
418
|
-
let userIp = "";
|
|
419
436
|
const token = localStorage.getItem('token');
|
|
420
|
-
|
|
421
|
-
userIp = res?.ip;
|
|
422
|
-
});
|
|
423
|
-
return new HttpHeaders({
|
|
437
|
+
const headers = {
|
|
424
438
|
'Content-Type': 'application/json',
|
|
425
439
|
Authorization: token ? `Bearer ${token}` : '',
|
|
426
|
-
|
|
427
|
-
|
|
440
|
+
};
|
|
441
|
+
if (this.attachCallerIp) {
|
|
442
|
+
headers['ip-address'] = await this.getCachedPublicIP();
|
|
443
|
+
}
|
|
444
|
+
return new HttpHeaders(headers);
|
|
445
|
+
}
|
|
446
|
+
cachedIp = null;
|
|
447
|
+
async getCachedPublicIP() {
|
|
448
|
+
if (this.cachedIp)
|
|
449
|
+
return this.cachedIp;
|
|
450
|
+
try {
|
|
451
|
+
const res = await firstValueFrom(this.getPublicIP());
|
|
452
|
+
this.cachedIp = res?.ip ?? '';
|
|
453
|
+
}
|
|
454
|
+
catch {
|
|
455
|
+
this.cachedIp = '';
|
|
456
|
+
}
|
|
457
|
+
return this.cachedIp;
|
|
428
458
|
}
|
|
429
459
|
getUploadHeaders() {
|
|
430
460
|
const token = localStorage.getItem('token');
|
|
@@ -7890,5 +7920,5 @@ const unsavedChangesGuard = () => {
|
|
|
7890
7920
|
* Generated bundle index. Do not edit.
|
|
7891
7921
|
*/
|
|
7892
7922
|
|
|
7893
|
-
export { array_util as ArrayUtil, date_util as DateUtil, DeleteConfirmation, DeleteConfirmationData, Dialog, DialogWrapper, DirtyStateService, DynamicForm, ErrorDialog, FormStructureModule, Httpbase, number_util as NumberUtil, object_util as ObjectUtil, OslAutocomplete, OslAutocompleteLister, OslBaseExtended, OslButton, OslCheckbox, OslDatepicker, OslDatetimepicker, OslDocumentUploader, OslFileUpload, OslFormGrid, OslGrid, OslMenu, OslMenuTriggerFor, OslRadio, OslReportForm, OslReportGrid, OslSearchbar, OslSelect, OslSetup, OslSkeletonDirective, OslSkeletonModule, OslSkeletonThemeService, OslSlideToggle, OslTooltipDirective, OslUserLog, Oslinput, Osltextarea, storage_util as StorageUtil, string_util as StringUtil, UnsavedChangesDialog, validation_util as ValidationUtil, baseComponent, unsavedChangesGuard };
|
|
7923
|
+
export { array_util as ArrayUtil, date_util as DateUtil, DeleteConfirmation, DeleteConfirmationData, Dialog, DialogWrapper, DirtyStateService, DynamicForm, ErrorDialog, FormStructureModule, Httpbase, number_util as NumberUtil, OSL_ATTACH_CALLER_IP, object_util as ObjectUtil, OslAutocomplete, OslAutocompleteLister, OslBaseExtended, OslButton, OslCheckbox, OslDatepicker, OslDatetimepicker, OslDocumentUploader, OslFileUpload, OslFormGrid, OslGrid, OslMenu, OslMenuTriggerFor, OslRadio, OslReportForm, OslReportGrid, OslSearchbar, OslSelect, OslSetup, OslSkeletonDirective, OslSkeletonModule, OslSkeletonThemeService, OslSlideToggle, OslTooltipDirective, OslUserLog, Oslinput, Osltextarea, storage_util as StorageUtil, string_util as StringUtil, UnsavedChangesDialog, validation_util as ValidationUtil, baseComponent, provideCallerIpHeader, unsavedChangesGuard };
|
|
7894
7924
|
//# sourceMappingURL=osl-base-extended.mjs.map
|