@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.d.cts
CHANGED
|
@@ -3,6 +3,19 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
import * as consola from 'consola';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Auth-related constants shared across the frontend.
|
|
8
|
+
* Single source of truth — do not redefine these elsewhere.
|
|
9
|
+
*/
|
|
10
|
+
declare const AUTH_CONSTANTS: {
|
|
11
|
+
/** Email OTP code length (numeric). */
|
|
12
|
+
readonly EMAIL_OTP_LENGTH: 4;
|
|
13
|
+
/** TOTP code length (RFC 6238 — authenticator apps). */
|
|
14
|
+
readonly TOTP_LENGTH: 6;
|
|
15
|
+
/** Backup code max length. */
|
|
16
|
+
readonly BACKUP_CODE_MAX_LENGTH: 12;
|
|
17
|
+
};
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* Nested serializer for Centrifugo WebSocket connection token.
|
|
8
21
|
*/
|
|
@@ -890,4 +903,4 @@ declare const Analytics: {
|
|
|
890
903
|
setUser(userId: string): void;
|
|
891
904
|
};
|
|
892
905
|
|
|
893
|
-
export { type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AuthConfig, type AuthContextType, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type OTPRequestResult, type PatchedCfgUserUpdateRequest, PatchedCfgUserUpdateRequestSchema, type ProfileCacheOptions, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UserProfile, authLogger, clearProfileCache, decodeBase64, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, logger, setCachedProfile, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthGuard, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSessionStorage, useTokenRefresh, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, validateEmail, validateIdentifier };
|
|
906
|
+
export { AUTH_CONSTANTS, type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AuthConfig, type AuthContextType, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type OTPRequestResult, type PatchedCfgUserUpdateRequest, PatchedCfgUserUpdateRequestSchema, type ProfileCacheOptions, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UserProfile, authLogger, clearProfileCache, decodeBase64, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, logger, setCachedProfile, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthGuard, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSessionStorage, useTokenRefresh, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, validateEmail, validateIdentifier };
|
package/dist/auth.d.ts
CHANGED
|
@@ -3,6 +3,19 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
import * as consola from 'consola';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Auth-related constants shared across the frontend.
|
|
8
|
+
* Single source of truth — do not redefine these elsewhere.
|
|
9
|
+
*/
|
|
10
|
+
declare const AUTH_CONSTANTS: {
|
|
11
|
+
/** Email OTP code length (numeric). */
|
|
12
|
+
readonly EMAIL_OTP_LENGTH: 4;
|
|
13
|
+
/** TOTP code length (RFC 6238 — authenticator apps). */
|
|
14
|
+
readonly TOTP_LENGTH: 6;
|
|
15
|
+
/** Backup code max length. */
|
|
16
|
+
readonly BACKUP_CODE_MAX_LENGTH: 12;
|
|
17
|
+
};
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* Nested serializer for Centrifugo WebSocket connection token.
|
|
8
21
|
*/
|
|
@@ -890,4 +903,4 @@ declare const Analytics: {
|
|
|
890
903
|
setUser(userId: string): void;
|
|
891
904
|
};
|
|
892
905
|
|
|
893
|
-
export { type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AuthConfig, type AuthContextType, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type OTPRequestResult, type PatchedCfgUserUpdateRequest, PatchedCfgUserUpdateRequestSchema, type ProfileCacheOptions, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UserProfile, authLogger, clearProfileCache, decodeBase64, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, logger, setCachedProfile, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthGuard, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSessionStorage, useTokenRefresh, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, validateEmail, validateIdentifier };
|
|
906
|
+
export { AUTH_CONSTANTS, type AccountsContextValue, AccountsProvider, Analytics, AnalyticsCategory, type AnalyticsCategoryType, AnalyticsEvent, type AnalyticsEventType, type AuthConfig, type AuthContextType, type AuthFormAutoSubmit, type AuthFormReturn, type AuthFormState, type AuthFormStateHandlers, type AuthFormSubmitHandlers, type AuthFormValidation, AuthProvider, type AuthProviderProps, type AuthStep, type DeleteAccountResult, type OTPRequestResult, type PatchedCfgUserUpdateRequest, PatchedCfgUserUpdateRequestSchema, type ProfileCacheOptions, type TwoFactorDevice, type TwoFactorSetupData, type UseAuthFormOptions, type UseAuthFormStateReturn, type UseAutoAuthOptions, type UseDeleteAccountReturn, type UseGithubAuthOptions, type UseGithubAuthReturn, type UseTwoFactorOptions, type UseTwoFactorReturn, type UseTwoFactorSetupOptions, type UseTwoFactorSetupReturn, type UseTwoFactorStatusReturn, type UserProfile, authLogger, clearProfileCache, decodeBase64, encodeBase64, formatAuthError, getCacheMetadata, getCachedProfile, hasValidCache, logger, setCachedProfile, useAccountsContext, useAuth, useAuthForm, useAuthFormState, useAuthGuard, useAuthRedirectManager, useAuthValidation, useAutoAuth, useBase64, useCfgRouter, useDeleteAccount, useGithubAuth, useLocalStorage, useQueryParams, useSessionStorage, useTokenRefresh, useTwoFactor, useTwoFactorSetup, useTwoFactorStatus, validateEmail, validateIdentifier };
|
package/dist/auth.mjs
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
4
|
|
|
5
|
+
// src/auth/constants.ts
|
|
6
|
+
var AUTH_CONSTANTS = {
|
|
7
|
+
/** Email OTP code length (numeric). */
|
|
8
|
+
EMAIL_OTP_LENGTH: 4,
|
|
9
|
+
/** TOTP code length (RFC 6238 — authenticator apps). */
|
|
10
|
+
TOTP_LENGTH: 6,
|
|
11
|
+
/** Backup code max length. */
|
|
12
|
+
BACKUP_CODE_MAX_LENGTH: 12
|
|
13
|
+
};
|
|
14
|
+
|
|
5
15
|
// src/auth/utils/env.ts
|
|
6
16
|
var isDev = process.env.NODE_ENV === "development";
|
|
7
17
|
var isBrowser = typeof window !== "undefined";
|
|
@@ -229,7 +239,7 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
229
239
|
useEffect3(() => {
|
|
230
240
|
if (!isReady) return;
|
|
231
241
|
const queryOtp = queryParams.get("otp");
|
|
232
|
-
if (queryOtp && typeof queryOtp === "string" && queryOtp.length ===
|
|
242
|
+
if (queryOtp && typeof queryOtp === "string" && queryOtp.length === AUTH_CONSTANTS.EMAIL_OTP_LENGTH) {
|
|
233
243
|
authLogger.info("OTP detected in URL on auth page:", queryOtp);
|
|
234
244
|
onOTPDetected?.(queryOtp);
|
|
235
245
|
}
|
|
@@ -485,6 +495,12 @@ function installAuthOnClient(client2) {
|
|
|
485
495
|
if (locale) request.headers.set("Accept-Language", locale);
|
|
486
496
|
const apiKey = auth.getApiKey();
|
|
487
497
|
if (apiKey) request.headers.set("X-API-Key", apiKey);
|
|
498
|
+
try {
|
|
499
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
500
|
+
if (tz) request.headers.set("X-Timezone", tz);
|
|
501
|
+
} catch {
|
|
502
|
+
}
|
|
503
|
+
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
488
504
|
return request;
|
|
489
505
|
});
|
|
490
506
|
client2.interceptors.response.use(async (response, request) => {
|
|
@@ -2745,8 +2761,8 @@ var useAuthForm = /* @__PURE__ */ __name((options) => {
|
|
|
2745
2761
|
sourceUrl
|
|
2746
2762
|
]);
|
|
2747
2763
|
const submitOTP = useCallback5(async (submitIdentifier, submitOtp) => {
|
|
2748
|
-
if (!submitOtp || submitOtp.length <
|
|
2749
|
-
const msg =
|
|
2764
|
+
if (!submitOtp || submitOtp.length < AUTH_CONSTANTS.EMAIL_OTP_LENGTH) {
|
|
2765
|
+
const msg = `Please enter the ${AUTH_CONSTANTS.EMAIL_OTP_LENGTH}-digit verification code`;
|
|
2750
2766
|
setError(msg);
|
|
2751
2767
|
onError?.(msg);
|
|
2752
2768
|
return false;
|
|
@@ -4805,6 +4821,7 @@ var formatAuthError = /* @__PURE__ */ __name((error) => {
|
|
|
4805
4821
|
return "An unexpected error occurred";
|
|
4806
4822
|
}, "formatAuthError");
|
|
4807
4823
|
export {
|
|
4824
|
+
AUTH_CONSTANTS,
|
|
4808
4825
|
AccountsProvider,
|
|
4809
4826
|
Analytics,
|
|
4810
4827
|
AnalyticsCategory,
|