@frank-auth/react
Version:
Flexible and customizable React UI components for Frank Authentication
151 lines (150 loc) • 4.51 kB
JavaScript
'use client';
import { jsx as s } from "react/jsx-runtime";
import c, { ApiErrorBoundary as l, FormErrorBoundary as w, AuthErrorBoundary as p, withErrorBoundary as R } from "./error-boundary.js";
import { ErrorBoundary as b, useAsyncError as K } from "./error-boundary.js";
import a, { LoadingButton as h, LoadingProvider as E } from "./loading-spinner.js";
import { LoadingSpinner as F, LoadingStates as W, useLoading as j } from "./loading-spinner.js";
import u, { MagicLinkVerification as d } from "./magic-link.js";
import { MagicLink as Y } from "./magic-link.js";
import m, { OAuthDivider as f } from "./oauth-buttons.js";
import { OAuthButtons as q } from "./oauth-buttons.js";
import g from "./redirect-handler.js";
import { RedirectHandler as Q, useRedirectHandler as X } from "./redirect-handler.js";
const y = {
LoadingSpinner: a,
LoadingButton: h,
ErrorBoundary: c,
RedirectHandler: g,
OAuthButtons: m,
OAuthDivider: f,
MagicLink: u,
MagicLinkVerification: d
}, N = {
LoadingSpinner: a,
LoadingButton: h,
LoadingProvider: E
}, T = {
ErrorBoundary: c,
AuthErrorBoundary: p,
FormErrorBoundary: w,
ApiErrorBoundary: l
}, P = {
OAuthButtons: m,
OAuthDivider: f
}, v = {
MagicLink: u,
MagicLinkVerification: d
}, k = {
LOADING: "loading",
SUCCESS: "success",
ERROR: "error",
IDLE: "idle",
PROCESSING: "processing",
VERIFYING: "verifying",
REDIRECTING: "redirecting"
}, U = {
NETWORK_ERROR: "network_error",
AUTHENTICATION_ERROR: "authentication_error",
AUTHORIZATION_ERROR: "authorization_error",
VALIDATION_ERROR: "validation_error",
TIMEOUT_ERROR: "timeout_error",
UNKNOWN_ERROR: "unknown_error"
}, B = {
OAUTH: "oauth",
MAGIC_LINK: "magic-link",
INVITATION: "invitation",
VERIFICATION: "verification",
ERROR: "error"
};
function C(r, o) {
const n = (t) => {
const { isLoading: e, ...i } = t;
return e ? /* @__PURE__ */ s(a, { ...o }) : /* @__PURE__ */ s(r, { ...i });
};
return n.displayName = `withLoading(${r.displayName || r.name})`, n;
}
function H(r, o) {
return R(r, {
title: "Authentication Error",
subtitle: "There was a problem with the authentication process.",
showDetails: process.env.NODE_ENV === "development",
...o
});
}
function x() {
if (typeof window > "u") return !1;
const r = new URLSearchParams(window.location.search), o = new URLSearchParams(window.location.hash.slice(1));
return !!(r.has("code") || o.has("code") || r.has("token") || o.has("token") || r.has("invitation_token") || r.has("invite") || r.has("error") || o.has("error"));
}
function D() {
if (typeof window > "u") return {};
const r = new URLSearchParams(window.location.search), o = new URLSearchParams(window.location.hash.slice(1)), n = {};
return [...r.entries(), ...o.entries()].forEach(([t, e]) => {
n[t] = e;
}), n;
}
function M() {
if (typeof window > "u") return;
const r = [
"code",
"state",
"error",
"error_description",
"token",
"type",
"invitation_token",
"invite",
"verification_token",
"verify"
], o = new URLSearchParams(window.location.search);
let n = !1;
if (r.forEach((t) => {
o.has(t) && (o.delete(t), n = !0);
}), n) {
const t = o.toString() ? `${window.location.pathname}?${o.toString()}` : window.location.pathname;
window.history.replaceState({}, document.title, t);
}
if (window.location.hash) {
const t = new URLSearchParams(window.location.hash.slice(1));
let e = !1;
if (r.forEach((i) => {
t.has(i) && (t.delete(i), e = !0);
}), e) {
const i = t.toString() ? `#${t.toString()}` : "";
window.history.replaceState({}, document.title, window.location.pathname + window.location.search + i);
}
}
}
export {
l as ApiErrorBoundary,
p as AuthErrorBoundary,
U as AuthErrorTypes,
k as AuthStates,
y as CommonAuthComponents,
b as ErrorBoundary,
T as ErrorComponents,
w as FormErrorBoundary,
h as LoadingButton,
N as LoadingComponents,
E as LoadingProvider,
F as LoadingSpinner,
W as LoadingStates,
Y as MagicLink,
v as MagicLinkComponents,
d as MagicLinkVerification,
q as OAuthButtons,
P as OAuthComponents,
f as OAuthDivider,
Q as RedirectHandler,
B as RedirectTypes,
M as cleanAuthParams,
D as getAuthParams,
x as isAuthRedirect,
K as useAsyncError,
j as useLoading,
X as useRedirectHandler,
H as withAuthErrorBoundary,
R as withErrorBoundary,
C as withLoading
};
//# sourceMappingURL=index.js.map