fix: commit vendored @kuns/zitadel-auth dist (was excluded by dist/ gitignore)

This commit is contained in:
2026-06-10 08:22:38 +00:00
parent 7331fe75e8
commit ab2f9affd1
24 changed files with 1707 additions and 1 deletions

51
vendor/zitadel-auth/dist/react.js vendored Normal file
View File

@@ -0,0 +1,51 @@
import {
ZitadelAuth
} from "./chunk-NFH7JLJM.js";
// src/adapters/react.tsx
import {
createContext,
useContext,
useEffect,
useState,
useSyncExternalStore
} from "react";
import { jsx } from "react/jsx-runtime";
var AuthContext = createContext(null);
function ZitadelProvider({ children, ...config }) {
const [auth] = useState(() => new ZitadelAuth(config));
const [ready, setReady] = useState(false);
useEffect(() => {
auth.init().then(() => {
setReady(true);
if (!auth.isAuthenticated && !auth.error) {
auth.login();
}
});
}, [auth]);
if (!ready) return null;
return /* @__PURE__ */ jsx(AuthContext.Provider, { value: auth, children });
}
function useAuth() {
const auth = useContext(AuthContext);
if (!auth) throw new Error("useAuth must be used within a ZitadelProvider");
const state = useSyncExternalStore(
(cb) => auth.onAuthChange(cb),
() => ({
isAuthenticated: auth.isAuthenticated,
isLoading: auth.isLoading,
user: auth.user,
error: auth.error
})
);
return {
...state,
login: () => auth.login(),
logout: () => auth.logout(),
fetch: (url, init) => auth.fetch(url, init)
};
}
export {
ZitadelProvider,
useAuth
};