@djangocfg/api 2.1.591 → 2.1.592
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/hooks.cjs
CHANGED
|
@@ -1297,6 +1297,14 @@ function defaultBaseUrl() {
|
|
|
1297
1297
|
return "";
|
|
1298
1298
|
}
|
|
1299
1299
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
1300
|
+
function detectTimezone() {
|
|
1301
|
+
try {
|
|
1302
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
1303
|
+
} catch {
|
|
1304
|
+
return null;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
__name(detectTimezone, "detectTimezone");
|
|
1300
1308
|
function defaultApiKey() {
|
|
1301
1309
|
try {
|
|
1302
1310
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -1308,6 +1316,7 @@ function defaultApiKey() {
|
|
|
1308
1316
|
}
|
|
1309
1317
|
__name(defaultApiKey, "defaultApiKey");
|
|
1310
1318
|
var _localeOverride = null;
|
|
1319
|
+
var _timezoneOverride = null;
|
|
1311
1320
|
var _apiKeyOverride = null;
|
|
1312
1321
|
var _baseUrlOverride = null;
|
|
1313
1322
|
var _withCredentials = true;
|
|
@@ -1534,6 +1543,14 @@ var auth = {
|
|
|
1534
1543
|
setLocale(locale) {
|
|
1535
1544
|
_localeOverride = locale;
|
|
1536
1545
|
},
|
|
1546
|
+
// ── Time zone ─────────────────────────────────────────────────────
|
|
1547
|
+
// IANA name sent as `X-Timezone`. `null` override = follow the browser.
|
|
1548
|
+
getTimezone() {
|
|
1549
|
+
return _timezoneOverride ?? detectTimezone();
|
|
1550
|
+
},
|
|
1551
|
+
setTimezone(timezone) {
|
|
1552
|
+
_timezoneOverride = timezone;
|
|
1553
|
+
},
|
|
1537
1554
|
// ── Base URL ──────────────────────────────────────────────────────
|
|
1538
1555
|
getBaseUrl() {
|
|
1539
1556
|
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
@@ -1741,11 +1758,8 @@ function installAuthOnClient(client2) {
|
|
|
1741
1758
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
1742
1759
|
const apiKey = auth.getApiKey();
|
|
1743
1760
|
if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
if (tz) request.headers.set("X-Timezone", tz);
|
|
1747
|
-
} catch {
|
|
1748
|
-
}
|
|
1761
|
+
const tz = auth.getTimezone();
|
|
1762
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
1749
1763
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
1750
1764
|
if (dpopEnabled() && typeof window !== "undefined") {
|
|
1751
1765
|
const proof = await _makeDpopProof(request.method, request.url);
|