osl-base-extended 12.8.0 → 13.0.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.
|
@@ -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;
|
|
@@ -414,18 +425,23 @@ class Httpbase {
|
|
|
414
425
|
// supports plain, unauthenticated CORS requests, so any interceptor that
|
|
415
426
|
// attaches Authorization/credentials to every request would break this call.
|
|
416
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;
|
|
417
431
|
getPublicIP() {
|
|
418
432
|
return this.plainHttp.get('https://api.ipify.org?format=json');
|
|
419
433
|
}
|
|
420
434
|
// ─── Internals ────────────────────────────────────────────────────────────────
|
|
421
435
|
async getHeaders() {
|
|
422
436
|
const token = localStorage.getItem('token');
|
|
423
|
-
const
|
|
424
|
-
return new HttpHeaders({
|
|
437
|
+
const headers = {
|
|
425
438
|
'Content-Type': 'application/json',
|
|
426
439
|
Authorization: token ? `Bearer ${token}` : '',
|
|
427
|
-
|
|
428
|
-
|
|
440
|
+
};
|
|
441
|
+
if (this.attachCallerIp) {
|
|
442
|
+
headers['ip-address'] = await this.getCachedPublicIP();
|
|
443
|
+
}
|
|
444
|
+
return new HttpHeaders(headers);
|
|
429
445
|
}
|
|
430
446
|
cachedIp = null;
|
|
431
447
|
async getCachedPublicIP() {
|
|
@@ -7904,5 +7920,5 @@ const unsavedChangesGuard = () => {
|
|
|
7904
7920
|
* Generated bundle index. Do not edit.
|
|
7905
7921
|
*/
|
|
7906
7922
|
|
|
7907
|
-
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 };
|
|
7908
7924
|
//# sourceMappingURL=osl-base-extended.mjs.map
|