@kinde-oss/kinde-auth-react
Version:
Kinde React SDK for authentication
69 lines (68 loc) • 1.63 kB
JavaScript
import { jsx as l } from "react/jsx-runtime";
import { useCallback as r } from "react";
import { u as c } from "./useKindeAuth-BArWbaqf.js";
function g({ children: e, ...t }) {
const n = c(), o = r(async () => {
n.login(t);
}, [n, t]);
return /* @__PURE__ */ l("button", { type: "button", ...t, onClick: (a) => {
t.onClick && t.onClick(a), o();
}, children: e });
}
function C({ children: e, ...t }) {
const n = c(), o = r(async () => {
n.register(t);
}, [n, t]);
return /* @__PURE__ */ l("button", { type: "button", ...t, onClick: (a) => {
t.onClick && t.onClick(a), o();
}, children: e });
}
function b({ children: e, ...t }) {
const n = c(), o = r(async () => {
n.logout({
redirectUrl: t.redirectUrl,
allSessions: t.allSessions
});
}, [n, t.redirectUrl, t.allSessions]);
return /* @__PURE__ */ l(
"button",
{
type: "button",
...t,
onClick: () => {
o();
},
children: e
}
);
}
function d({ children: e, ...t }) {
const n = c(), o = r(async () => {
try {
const i = await n.generatePortalUrl({
subNav: t.subNav,
returnUrl: t.returnUrl || window.location.href
});
window.location.href = i.url.toString();
} catch (i) {
console.error("Failed to generate portal URL:", i);
}
}, [n, t.returnUrl, t.subNav]);
return /* @__PURE__ */ l(
"button",
{
type: "button",
...t,
onClick: async () => {
await o();
},
children: e
}
);
}
export {
g as LoginLink,
b as LogoutLink,
d as PortalLink,
C as RegisterLink
};