@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/index.cjs
CHANGED
|
@@ -439,6 +439,14 @@ function defaultBaseUrl() {
|
|
|
439
439
|
return "";
|
|
440
440
|
}
|
|
441
441
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
442
|
+
function detectTimezone() {
|
|
443
|
+
try {
|
|
444
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
445
|
+
} catch {
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
__name(detectTimezone, "detectTimezone");
|
|
442
450
|
function defaultApiKey() {
|
|
443
451
|
try {
|
|
444
452
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -450,6 +458,7 @@ function defaultApiKey() {
|
|
|
450
458
|
}
|
|
451
459
|
__name(defaultApiKey, "defaultApiKey");
|
|
452
460
|
var _localeOverride = null;
|
|
461
|
+
var _timezoneOverride = null;
|
|
453
462
|
var _apiKeyOverride = null;
|
|
454
463
|
var _baseUrlOverride = null;
|
|
455
464
|
var _withCredentials = true;
|
|
@@ -676,6 +685,14 @@ var auth = {
|
|
|
676
685
|
setLocale(locale) {
|
|
677
686
|
_localeOverride = locale;
|
|
678
687
|
},
|
|
688
|
+
// ── Time zone ─────────────────────────────────────────────────────
|
|
689
|
+
// IANA name sent as `X-Timezone`. `null` override = follow the browser.
|
|
690
|
+
getTimezone() {
|
|
691
|
+
return _timezoneOverride ?? detectTimezone();
|
|
692
|
+
},
|
|
693
|
+
setTimezone(timezone) {
|
|
694
|
+
_timezoneOverride = timezone;
|
|
695
|
+
},
|
|
679
696
|
// ── Base URL ──────────────────────────────────────────────────────
|
|
680
697
|
getBaseUrl() {
|
|
681
698
|
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
@@ -883,11 +900,8 @@ function installAuthOnClient(client2) {
|
|
|
883
900
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
884
901
|
const apiKey = auth.getApiKey();
|
|
885
902
|
if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
if (tz) request.headers.set("X-Timezone", tz);
|
|
889
|
-
} catch {
|
|
890
|
-
}
|
|
903
|
+
const tz = auth.getTimezone();
|
|
904
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
891
905
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
892
906
|
if (dpopEnabled() && typeof window !== "undefined") {
|
|
893
907
|
const proof = await _makeDpopProof(request.method, request.url);
|