@djangocfg/api 2.1.346 → 2.1.348
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-server.cjs +6 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +6 -0
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +20 -3
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +14 -1
- package/dist/auth.d.ts +14 -1
- package/dist/auth.mjs +20 -3
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.mjs.map +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/helpers/auth.ts +6 -0
- package/src/_api/generated/index.ts +7 -0
- package/src/auth/constants.ts +13 -0
- package/src/auth/hooks/useAuthForm.ts +3 -2
- package/src/auth/hooks/useAutoAuth.ts +2 -1
- package/src/auth/index.ts +3 -0
package/dist/auth.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/auth/index.ts
|
|
32
32
|
var auth_exports = {};
|
|
33
33
|
__export(auth_exports, {
|
|
34
|
+
AUTH_CONSTANTS: () => AUTH_CONSTANTS,
|
|
34
35
|
AccountsProvider: () => AccountsProvider,
|
|
35
36
|
Analytics: () => Analytics,
|
|
36
37
|
AnalyticsCategory: () => AnalyticsCategory,
|
|
@@ -71,6 +72,16 @@ __export(auth_exports, {
|
|
|
71
72
|
});
|
|
72
73
|
module.exports = __toCommonJS(auth_exports);
|
|
73
74
|
|
|
75
|
+
// src/auth/constants.ts
|
|
76
|
+
var AUTH_CONSTANTS = {
|
|
77
|
+
/** Email OTP code length (numeric). */
|
|
78
|
+
EMAIL_OTP_LENGTH: 4,
|
|
79
|
+
/** TOTP code length (RFC 6238 — authenticator apps). */
|
|
80
|
+
TOTP_LENGTH: 6,
|
|
81
|
+
/** Backup code max length. */
|
|
82
|
+
BACKUP_CODE_MAX_LENGTH: 12
|
|
83
|
+
};
|
|
84
|
+
|
|
74
85
|
// src/auth/utils/env.ts
|
|
75
86
|
var isDev = process.env.NODE_ENV === "development";
|
|
76
87
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -290,7 +301,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
290
301
|
(0, import_react5.useEffect)(() => {
|
|
291
302
|
if (!isReady) return;
|
|
292
303
|
const queryOtp = queryParams.get("otp");
|
|
293
|
-
if (queryOtp && typeof queryOtp === "string" && queryOtp.length ===
|
|
304
|
+
if (queryOtp && typeof queryOtp === "string" && queryOtp.length === AUTH_CONSTANTS.EMAIL_OTP_LENGTH) {
|
|
294
305
|
authLogger.info("OTP detected in URL on auth page:", queryOtp);
|
|
295
306
|
onOTPDetected?.(queryOtp);
|
|
296
307
|
}
|
|
@@ -546,6 +557,12 @@ function installAuthOnClient(client2) {
|
|
|
546
557
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
547
558
|
const apiKey = auth.getApiKey();
|
|
548
559
|
if (apiKey) request.headers.set("X-API-Key", apiKey);
|
|
560
|
+
try {
|
|
561
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
562
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
563
|
+
} catch {
|
|
564
|
+
}
|
|
565
|
+
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
549
566
|
return request;
|
|
550
567
|
});
|
|
551
568
|
client2.interceptors.response.use(async (response, request) => {
|
|
@@ -2806,8 +2823,8 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2806
2823
|
sourceUrl
|
|
2807
2824
|
]);
|
|
2808
2825
|
const submitOTP = (0, import_react7.useCallback)(async (submitIdentifier, submitOtp) => {
|
|
2809
|
-
if (!submitOtp || submitOtp.length <
|
|
2810
|
-
const msg =
|
|
2826
|
+
if (!submitOtp || submitOtp.length < AUTH_CONSTANTS.EMAIL_OTP_LENGTH) {
|
|
2827
|
+
const msg = `Please enter the ${AUTH_CONSTANTS.EMAIL_OTP_LENGTH}-digit verification code`;
|
|
2811
2828
|
setError(msg);
|
|
2812
2829
|
onError?.(msg);
|
|
2813
2830
|
return false;
|