@djangocfg/api 2.1.590 → 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.mjs
CHANGED
|
@@ -1162,6 +1162,14 @@ function defaultBaseUrl() {
|
|
|
1162
1162
|
return "";
|
|
1163
1163
|
}
|
|
1164
1164
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
1165
|
+
function detectTimezone() {
|
|
1166
|
+
try {
|
|
1167
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
1168
|
+
} catch {
|
|
1169
|
+
return null;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
__name(detectTimezone, "detectTimezone");
|
|
1165
1173
|
function defaultApiKey() {
|
|
1166
1174
|
try {
|
|
1167
1175
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -1173,6 +1181,7 @@ function defaultApiKey() {
|
|
|
1173
1181
|
}
|
|
1174
1182
|
__name(defaultApiKey, "defaultApiKey");
|
|
1175
1183
|
var _localeOverride = null;
|
|
1184
|
+
var _timezoneOverride = null;
|
|
1176
1185
|
var _apiKeyOverride = null;
|
|
1177
1186
|
var _baseUrlOverride = null;
|
|
1178
1187
|
var _withCredentials = true;
|
|
@@ -1399,6 +1408,14 @@ var auth = {
|
|
|
1399
1408
|
setLocale(locale) {
|
|
1400
1409
|
_localeOverride = locale;
|
|
1401
1410
|
},
|
|
1411
|
+
// ── Time zone ─────────────────────────────────────────────────────
|
|
1412
|
+
// IANA name sent as `X-Timezone`. `null` override = follow the browser.
|
|
1413
|
+
getTimezone() {
|
|
1414
|
+
return _timezoneOverride ?? detectTimezone();
|
|
1415
|
+
},
|
|
1416
|
+
setTimezone(timezone) {
|
|
1417
|
+
_timezoneOverride = timezone;
|
|
1418
|
+
},
|
|
1402
1419
|
// ── Base URL ──────────────────────────────────────────────────────
|
|
1403
1420
|
getBaseUrl() {
|
|
1404
1421
|
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
@@ -1606,11 +1623,8 @@ function installAuthOnClient(client2) {
|
|
|
1606
1623
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
1607
1624
|
const apiKey = auth.getApiKey();
|
|
1608
1625
|
if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
if (tz) request.headers.set("X-Timezone", tz);
|
|
1612
|
-
} catch {
|
|
1613
|
-
}
|
|
1626
|
+
const tz = auth.getTimezone();
|
|
1627
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
1614
1628
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
1615
1629
|
if (dpopEnabled() && typeof window !== "undefined") {
|
|
1616
1630
|
const proof = await _makeDpopProof(request.method, request.url);
|