@djangocfg/api 2.1.591 → 2.1.593
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.
- package/dist/auth.cjs +214 -154
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +12 -1
- package/dist/auth.d.ts +12 -1
- package/dist/auth.mjs +137 -77
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +19 -5
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.mjs +19 -5
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +19 -5
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +19 -5
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +19 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +19 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/helpers/auth.ts +17 -4
- package/src/auth/__tests__/timezone.test.ts +18 -0
- package/src/auth/hooks/index.ts +3 -0
- package/src/auth/hooks/useTimezone.ts +67 -0
package/dist/clients.mjs
CHANGED
|
@@ -364,6 +364,14 @@ function defaultBaseUrl() {
|
|
|
364
364
|
return "";
|
|
365
365
|
}
|
|
366
366
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
367
|
+
function detectTimezone() {
|
|
368
|
+
try {
|
|
369
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
370
|
+
} catch {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
__name(detectTimezone, "detectTimezone");
|
|
367
375
|
function defaultApiKey() {
|
|
368
376
|
try {
|
|
369
377
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -375,6 +383,7 @@ function defaultApiKey() {
|
|
|
375
383
|
}
|
|
376
384
|
__name(defaultApiKey, "defaultApiKey");
|
|
377
385
|
var _localeOverride = null;
|
|
386
|
+
var _timezoneOverride = null;
|
|
378
387
|
var _apiKeyOverride = null;
|
|
379
388
|
var _baseUrlOverride = null;
|
|
380
389
|
var _withCredentials = true;
|
|
@@ -601,6 +610,14 @@ var auth = {
|
|
|
601
610
|
setLocale(locale) {
|
|
602
611
|
_localeOverride = locale;
|
|
603
612
|
},
|
|
613
|
+
// ── Time zone ─────────────────────────────────────────────────────
|
|
614
|
+
// IANA name sent as `X-Timezone`. `null` override = follow the browser.
|
|
615
|
+
getTimezone() {
|
|
616
|
+
return _timezoneOverride ?? detectTimezone();
|
|
617
|
+
},
|
|
618
|
+
setTimezone(timezone) {
|
|
619
|
+
_timezoneOverride = timezone;
|
|
620
|
+
},
|
|
604
621
|
// ── Base URL ──────────────────────────────────────────────────────
|
|
605
622
|
getBaseUrl() {
|
|
606
623
|
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
@@ -808,11 +825,8 @@ function installAuthOnClient(client2) {
|
|
|
808
825
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
809
826
|
const apiKey = auth.getApiKey();
|
|
810
827
|
if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
if (tz) request.headers.set("X-Timezone", tz);
|
|
814
|
-
} catch {
|
|
815
|
-
}
|
|
828
|
+
const tz = auth.getTimezone();
|
|
829
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
816
830
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
817
831
|
if (dpopEnabled() && typeof window !== "undefined") {
|
|
818
832
|
const proof = await _makeDpopProof(request.method, request.url);
|