@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.cjs
CHANGED
|
@@ -391,6 +391,14 @@ function defaultBaseUrl() {
|
|
|
391
391
|
return "";
|
|
392
392
|
}
|
|
393
393
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
394
|
+
function detectTimezone() {
|
|
395
|
+
try {
|
|
396
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
397
|
+
} catch {
|
|
398
|
+
return null;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
__name(detectTimezone, "detectTimezone");
|
|
394
402
|
function defaultApiKey() {
|
|
395
403
|
try {
|
|
396
404
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -402,6 +410,7 @@ function defaultApiKey() {
|
|
|
402
410
|
}
|
|
403
411
|
__name(defaultApiKey, "defaultApiKey");
|
|
404
412
|
var _localeOverride = null;
|
|
413
|
+
var _timezoneOverride = null;
|
|
405
414
|
var _apiKeyOverride = null;
|
|
406
415
|
var _baseUrlOverride = null;
|
|
407
416
|
var _withCredentials = true;
|
|
@@ -628,6 +637,14 @@ var auth = {
|
|
|
628
637
|
setLocale(locale) {
|
|
629
638
|
_localeOverride = locale;
|
|
630
639
|
},
|
|
640
|
+
// ── Time zone ─────────────────────────────────────────────────────
|
|
641
|
+
// IANA name sent as `X-Timezone`. `null` override = follow the browser.
|
|
642
|
+
getTimezone() {
|
|
643
|
+
return _timezoneOverride ?? detectTimezone();
|
|
644
|
+
},
|
|
645
|
+
setTimezone(timezone) {
|
|
646
|
+
_timezoneOverride = timezone;
|
|
647
|
+
},
|
|
631
648
|
// ── Base URL ──────────────────────────────────────────────────────
|
|
632
649
|
getBaseUrl() {
|
|
633
650
|
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
@@ -835,11 +852,8 @@ function installAuthOnClient(client2) {
|
|
|
835
852
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
836
853
|
const apiKey = auth.getApiKey();
|
|
837
854
|
if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
if (tz) request.headers.set("X-Timezone", tz);
|
|
841
|
-
} catch {
|
|
842
|
-
}
|
|
855
|
+
const tz = auth.getTimezone();
|
|
856
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
843
857
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
844
858
|
if (dpopEnabled() && typeof window !== "undefined") {
|
|
845
859
|
const proof = await _makeDpopProof(request.method, request.url);
|