@djangocfg/api 2.1.95 → 2.1.97
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 +51 -1
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +6 -0
- package/dist/auth.d.ts +6 -0
- package/dist/auth.mjs +51 -1
- package/dist/auth.mjs.map +1 -1
- package/package.json +3 -3
- package/src/auth/context/AuthContext.tsx +62 -1
package/dist/auth.d.cts
CHANGED
|
@@ -307,6 +307,12 @@ interface AuthProviderProps {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
declare const AuthProvider: React$1.FC<AuthProviderProps>;
|
|
310
|
+
/**
|
|
311
|
+
* Hook to access auth context
|
|
312
|
+
*
|
|
313
|
+
* SSR-safe: Returns default unauthenticated state when called outside AuthProvider
|
|
314
|
+
* (e.g., during static page generation or server-side rendering)
|
|
315
|
+
*/
|
|
310
316
|
declare const useAuth: () => AuthContextType;
|
|
311
317
|
|
|
312
318
|
interface AccountsContextValue {
|
package/dist/auth.d.ts
CHANGED
|
@@ -307,6 +307,12 @@ interface AuthProviderProps {
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
declare const AuthProvider: React$1.FC<AuthProviderProps>;
|
|
310
|
+
/**
|
|
311
|
+
* Hook to access auth context
|
|
312
|
+
*
|
|
313
|
+
* SSR-safe: Returns default unauthenticated state when called outside AuthProvider
|
|
314
|
+
* (e.g., during static page generation or server-side rendering)
|
|
315
|
+
*/
|
|
310
316
|
declare const useAuth: () => AuthContextType;
|
|
311
317
|
|
|
312
318
|
interface AccountsContextValue {
|
package/dist/auth.mjs
CHANGED
|
@@ -4712,10 +4712,60 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
|
|
|
4712
4712
|
var AuthProvider = /* @__PURE__ */ __name(({ children, config }) => {
|
|
4713
4713
|
return /* @__PURE__ */ jsx2(AccountsProvider, { children: /* @__PURE__ */ jsx2(AuthProviderInternal, { config, children }) });
|
|
4714
4714
|
}, "AuthProvider");
|
|
4715
|
+
var defaultAuthState = {
|
|
4716
|
+
user: null,
|
|
4717
|
+
isLoading: false,
|
|
4718
|
+
isAuthenticated: false,
|
|
4719
|
+
isAdminUser: false,
|
|
4720
|
+
loadCurrentProfile: /* @__PURE__ */ __name(async () => {
|
|
4721
|
+
authLogger.warn("useAuth: loadCurrentProfile called outside AuthProvider");
|
|
4722
|
+
}, "loadCurrentProfile"),
|
|
4723
|
+
checkAuthAndRedirect: /* @__PURE__ */ __name(async () => {
|
|
4724
|
+
authLogger.warn("useAuth: checkAuthAndRedirect called outside AuthProvider");
|
|
4725
|
+
}, "checkAuthAndRedirect"),
|
|
4726
|
+
getToken: /* @__PURE__ */ __name(() => null, "getToken"),
|
|
4727
|
+
getRefreshToken: /* @__PURE__ */ __name(() => null, "getRefreshToken"),
|
|
4728
|
+
getSavedEmail: /* @__PURE__ */ __name(() => null, "getSavedEmail"),
|
|
4729
|
+
saveEmail: /* @__PURE__ */ __name(() => {
|
|
4730
|
+
authLogger.warn("useAuth: saveEmail called outside AuthProvider");
|
|
4731
|
+
}, "saveEmail"),
|
|
4732
|
+
clearSavedEmail: /* @__PURE__ */ __name(() => {
|
|
4733
|
+
}, "clearSavedEmail"),
|
|
4734
|
+
getSavedPhone: /* @__PURE__ */ __name(() => null, "getSavedPhone"),
|
|
4735
|
+
savePhone: /* @__PURE__ */ __name(() => {
|
|
4736
|
+
authLogger.warn("useAuth: savePhone called outside AuthProvider");
|
|
4737
|
+
}, "savePhone"),
|
|
4738
|
+
clearSavedPhone: /* @__PURE__ */ __name(() => {
|
|
4739
|
+
}, "clearSavedPhone"),
|
|
4740
|
+
requestOTP: /* @__PURE__ */ __name(async () => {
|
|
4741
|
+
authLogger.warn("useAuth: requestOTP called outside AuthProvider");
|
|
4742
|
+
return { success: false, message: "AuthProvider not available" };
|
|
4743
|
+
}, "requestOTP"),
|
|
4744
|
+
verifyOTP: /* @__PURE__ */ __name(async () => {
|
|
4745
|
+
authLogger.warn("useAuth: verifyOTP called outside AuthProvider");
|
|
4746
|
+
return { success: false, message: "AuthProvider not available" };
|
|
4747
|
+
}, "verifyOTP"),
|
|
4748
|
+
refreshToken: /* @__PURE__ */ __name(async () => {
|
|
4749
|
+
authLogger.warn("useAuth: refreshToken called outside AuthProvider");
|
|
4750
|
+
return { success: false, message: "AuthProvider not available" };
|
|
4751
|
+
}, "refreshToken"),
|
|
4752
|
+
logout: /* @__PURE__ */ __name(async () => {
|
|
4753
|
+
authLogger.warn("useAuth: logout called outside AuthProvider");
|
|
4754
|
+
}, "logout"),
|
|
4755
|
+
saveRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
4756
|
+
}, "saveRedirectUrl"),
|
|
4757
|
+
getRedirectUrl: /* @__PURE__ */ __name(() => null, "getRedirectUrl"),
|
|
4758
|
+
clearRedirectUrl: /* @__PURE__ */ __name(() => {
|
|
4759
|
+
}, "clearRedirectUrl"),
|
|
4760
|
+
hasRedirectUrl: /* @__PURE__ */ __name(() => false, "hasRedirectUrl")
|
|
4761
|
+
};
|
|
4715
4762
|
var useAuth = /* @__PURE__ */ __name(() => {
|
|
4716
4763
|
const context = useContext2(AuthContext);
|
|
4717
4764
|
if (context === void 0) {
|
|
4718
|
-
|
|
4765
|
+
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
4766
|
+
authLogger.debug("useAuth called outside AuthProvider, returning default state");
|
|
4767
|
+
}
|
|
4768
|
+
return defaultAuthState;
|
|
4719
4769
|
}
|
|
4720
4770
|
return context;
|
|
4721
4771
|
}, "useAuth");
|