@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/index.d.cts
CHANGED
|
@@ -105,6 +105,8 @@ declare const auth: {
|
|
|
105
105
|
clearApiKey(): void;
|
|
106
106
|
getLocale(): string | null;
|
|
107
107
|
setLocale(locale: string | null): void;
|
|
108
|
+
getTimezone(): string | null;
|
|
109
|
+
setTimezone(timezone: string | null): void;
|
|
108
110
|
getBaseUrl(): string;
|
|
109
111
|
setBaseUrl(url: string | null): void;
|
|
110
112
|
getWithCredentials(): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,8 @@ declare const auth: {
|
|
|
105
105
|
clearApiKey(): void;
|
|
106
106
|
getLocale(): string | null;
|
|
107
107
|
setLocale(locale: string | null): void;
|
|
108
|
+
getTimezone(): string | null;
|
|
109
|
+
setTimezone(timezone: string | null): void;
|
|
108
110
|
getBaseUrl(): string;
|
|
109
111
|
setBaseUrl(url: string | null): void;
|
|
110
112
|
getWithCredentials(): boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -376,6 +376,14 @@ function defaultBaseUrl() {
|
|
|
376
376
|
return "";
|
|
377
377
|
}
|
|
378
378
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
379
|
+
function detectTimezone() {
|
|
380
|
+
try {
|
|
381
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
382
|
+
} catch {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
__name(detectTimezone, "detectTimezone");
|
|
379
387
|
function defaultApiKey() {
|
|
380
388
|
try {
|
|
381
389
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
@@ -387,6 +395,7 @@ function defaultApiKey() {
|
|
|
387
395
|
}
|
|
388
396
|
__name(defaultApiKey, "defaultApiKey");
|
|
389
397
|
var _localeOverride = null;
|
|
398
|
+
var _timezoneOverride = null;
|
|
390
399
|
var _apiKeyOverride = null;
|
|
391
400
|
var _baseUrlOverride = null;
|
|
392
401
|
var _withCredentials = true;
|
|
@@ -613,6 +622,14 @@ var auth = {
|
|
|
613
622
|
setLocale(locale) {
|
|
614
623
|
_localeOverride = locale;
|
|
615
624
|
},
|
|
625
|
+
// ── Time zone ─────────────────────────────────────────────────────
|
|
626
|
+
// IANA name sent as `X-Timezone`. `null` override = follow the browser.
|
|
627
|
+
getTimezone() {
|
|
628
|
+
return _timezoneOverride ?? detectTimezone();
|
|
629
|
+
},
|
|
630
|
+
setTimezone(timezone) {
|
|
631
|
+
_timezoneOverride = timezone;
|
|
632
|
+
},
|
|
616
633
|
// ── Base URL ──────────────────────────────────────────────────────
|
|
617
634
|
getBaseUrl() {
|
|
618
635
|
const url = _baseUrlOverride ?? defaultBaseUrl();
|
|
@@ -820,11 +837,8 @@ function installAuthOnClient(client2) {
|
|
|
820
837
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
821
838
|
const apiKey = auth.getApiKey();
|
|
822
839
|
if (apiKey && !request.headers.has("X-API-Key")) request.headers.set("X-API-Key", apiKey);
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
if (tz) request.headers.set("X-Timezone", tz);
|
|
826
|
-
} catch {
|
|
827
|
-
}
|
|
840
|
+
const tz = auth.getTimezone();
|
|
841
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
828
842
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
829
843
|
if (dpopEnabled() && typeof window !== "undefined") {
|
|
830
844
|
const proof = await _makeDpopProof(request.method, request.url);
|