@liedsonc/core-auth-kit 2.1.4 → 2.1.6
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/README.md +802 -0
- package/dist/components/auth-card.d.ts +10 -0
- package/dist/components/auth-card.d.ts.map +1 -0
- package/dist/components/auth-card.js +10 -0
- package/dist/components/auth-form.d.ts +10 -0
- package/dist/components/auth-form.d.ts.map +1 -0
- package/dist/components/auth-form.js +21 -0
- package/dist/components/error-message.d.ts +6 -0
- package/dist/components/error-message.d.ts.map +1 -0
- package/dist/components/error-message.js +8 -0
- package/dist/components/form-field.d.ts +9 -0
- package/dist/components/form-field.d.ts.map +1 -0
- package/dist/components/form-field.js +7 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/{components/index.ts → dist/components/index.js} +8 -8
- package/dist/components/loading-spinner.d.ts +5 -0
- package/dist/components/loading-spinner.d.ts.map +1 -0
- package/dist/components/loading-spinner.js +6 -0
- package/dist/components/oauth-buttons.d.ts +11 -0
- package/dist/components/oauth-buttons.d.ts.map +1 -0
- package/dist/components/oauth-buttons.js +14 -0
- package/dist/components/password-input.d.ts +8 -0
- package/dist/components/password-input.d.ts.map +1 -0
- package/dist/components/password-input.js +36 -0
- package/dist/components/success-message.d.ts +6 -0
- package/dist/components/success-message.d.ts.map +1 -0
- package/dist/components/success-message.js +8 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +33 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +16 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +8 -0
- package/dist/components/ui/label.d.ts +6 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +10 -0
- package/dist/context.d.ts +8 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +13 -0
- package/dist/hooks/use-auth.d.ts +22 -0
- package/dist/hooks/use-auth.d.ts.map +1 -0
- package/dist/hooks/use-auth.js +112 -0
- package/dist/hooks/use-oauth.d.ts +6 -0
- package/dist/hooks/use-oauth.d.ts.map +1 -0
- package/dist/hooks/use-oauth.js +18 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/pages/forgot-password/index.d.ts +2 -0
- package/dist/pages/forgot-password/index.d.ts.map +1 -0
- package/dist/pages/forgot-password/index.js +30 -0
- package/dist/pages/index.d.ts +6 -0
- package/dist/pages/index.d.ts.map +1 -0
- package/{pages/index.ts → dist/pages/index.js} +5 -5
- package/dist/pages/login/index.d.ts +2 -0
- package/dist/pages/login/index.d.ts.map +1 -0
- package/dist/pages/login/index.js +45 -0
- package/dist/pages/register/index.d.ts +2 -0
- package/dist/pages/register/index.d.ts.map +1 -0
- package/dist/pages/register/index.js +59 -0
- package/dist/pages/reset-password/index.d.ts +2 -0
- package/dist/pages/reset-password/index.d.ts.map +1 -0
- package/dist/pages/reset-password/index.js +48 -0
- package/dist/pages/verify-email/index.d.ts +2 -0
- package/dist/pages/verify-email/index.d.ts.map +1 -0
- package/dist/pages/verify-email/index.js +47 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +5 -0
- package/package.json +15 -11
- package/components/auth-card.tsx +0 -49
- package/components/auth-form.tsx +0 -53
- package/components/error-message.tsx +0 -24
- package/components/form-field.tsx +0 -39
- package/components/loading-spinner.tsx +0 -19
- package/components/oauth-buttons.tsx +0 -49
- package/components/password-input.tsx +0 -93
- package/components/success-message.tsx +0 -24
- package/components/ui/button.tsx +0 -52
- package/components/ui/card.tsx +0 -75
- package/components/ui/input.tsx +0 -21
- package/components/ui/label.tsx +0 -25
- package/context.tsx +0 -26
- package/hooks/use-auth.ts +0 -131
- package/hooks/use-oauth.ts +0 -25
- package/index.ts +0 -28
- package/pages/forgot-password/index.tsx +0 -83
- package/pages/login/index.tsx +0 -119
- package/pages/register/index.tsx +0 -149
- package/pages/reset-password/index.tsx +0 -133
- package/pages/verify-email/index.tsx +0 -143
- package/types/index.ts +0 -34
- package/utils.ts +0 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "../styles/index.css";
|
|
2
|
+
export interface AuthCardProps {
|
|
3
|
+
title: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
footer?: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function AuthCard({ title, subtitle, children, footer, className, }: AuthCardProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=auth-card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-card.d.ts","sourceRoot":"","sources":["../../components/auth-card.tsx"],"names":[],"mappings":"AAYA,OAAO,qBAAqB,CAAC;AAE7B,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,GACV,EAAE,aAAa,2CAoBf"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "./ui/card";
|
|
4
|
+
import { useAuthUIConfig } from "../context";
|
|
5
|
+
import { cn } from "../utils";
|
|
6
|
+
import "../styles/index.css";
|
|
7
|
+
export function AuthCard({ title, subtitle, children, footer, className, }) {
|
|
8
|
+
const config = useAuthUIConfig();
|
|
9
|
+
return (_jsxs(Card, { className: cn("auth-ui-card", className), children: [_jsxs(CardHeader, { className: "space-y-1", children: [config.logo && (_jsx("div", { className: "flex justify-center mb-2", "aria-hidden": "true", children: config.logo })), _jsx(CardTitle, { className: "text-center", children: title }), subtitle && (_jsx(CardDescription, { className: "text-center", children: subtitle }))] }), _jsx(CardContent, { children: children }), footer && _jsx(CardFooter, { className: "flex flex-col gap-2", children: footer })] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface AuthFormProps extends Omit<React.FormHTMLAttributes<HTMLFormElement>, "onSubmit"> {
|
|
3
|
+
onSubmit: (e: React.FormEvent<HTMLFormElement>) => void | Promise<void>;
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
error?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function AuthForm({ onSubmit, loading, error, children, className, ...props }: AuthFormProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=auth-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-form.d.ts","sourceRoot":"","sources":["../../components/auth-form.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,WAAW,aACf,SAAQ,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;IACnE,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,OAAe,EACf,KAAK,EACL,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,aAAa,2CA+Bf"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../utils";
|
|
5
|
+
export function AuthForm({ onSubmit, loading = false, error, children, className, ...props }) {
|
|
6
|
+
const [submitting, setSubmitting] = React.useState(false);
|
|
7
|
+
const isDisabled = loading || submitting;
|
|
8
|
+
const handleSubmit = async (e) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
if (isDisabled)
|
|
11
|
+
return;
|
|
12
|
+
setSubmitting(true);
|
|
13
|
+
try {
|
|
14
|
+
await onSubmit(e);
|
|
15
|
+
}
|
|
16
|
+
finally {
|
|
17
|
+
setSubmitting(false);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, className: cn("space-y-4", className), "aria-busy": isDisabled, ...props, children: [error && (_jsx("p", { role: "alert", className: "text-sm text-destructive", children: error })), children] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../../components/error-message.tsx"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,EAAE,GACH,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,kDAWA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../utils";
|
|
4
|
+
export function ErrorMessage({ children, className, id, }) {
|
|
5
|
+
if (!children)
|
|
6
|
+
return null;
|
|
7
|
+
return (_jsx("p", { id: id, role: "alert", className: cn("text-sm text-destructive", className), children: children }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function FormField({ label, htmlFor, error, children, required, className, }: {
|
|
2
|
+
label: string;
|
|
3
|
+
htmlFor: string;
|
|
4
|
+
error?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=form-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-field.d.ts","sourceRoot":"","sources":["../../components/form-field.tsx"],"names":[],"mappings":"AAKA,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAmBA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Label } from "./ui/label";
|
|
4
|
+
import { cn } from "../utils";
|
|
5
|
+
export function FormField({ label, htmlFor, error, children, required, className, }) {
|
|
6
|
+
return (_jsxs("div", { className: cn("space-y-2", className), children: [_jsxs(Label, { htmlFor: htmlFor, children: [label, required && (_jsx("span", { className: "text-destructive ml-0.5", "aria-hidden": "true", children: "*" }))] }), children, error && (_jsx("p", { id: `${htmlFor}-error`, role: "alert", className: "text-sm text-destructive", children: error }))] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { AuthCard } from "./auth-card";
|
|
2
|
+
export { AuthForm } from "./auth-form";
|
|
3
|
+
export { ErrorMessage } from "./error-message";
|
|
4
|
+
export { FormField } from "./form-field";
|
|
5
|
+
export { LoadingSpinner } from "./loading-spinner";
|
|
6
|
+
export { OAuthButtons } from "./oauth-buttons";
|
|
7
|
+
export { PasswordInput } from "./password-input";
|
|
8
|
+
export { SuccessMessage } from "./success-message";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { AuthCard } from "./auth-card";
|
|
2
|
-
export { AuthForm } from "./auth-form";
|
|
3
|
-
export { ErrorMessage } from "./error-message";
|
|
4
|
-
export { FormField } from "./form-field";
|
|
5
|
-
export { LoadingSpinner } from "./loading-spinner";
|
|
6
|
-
export { OAuthButtons } from "./oauth-buttons";
|
|
7
|
-
export { PasswordInput } from "./password-input";
|
|
8
|
-
export { SuccessMessage } from "./success-message";
|
|
1
|
+
export { AuthCard } from "./auth-card";
|
|
2
|
+
export { AuthForm } from "./auth-form";
|
|
3
|
+
export { ErrorMessage } from "./error-message";
|
|
4
|
+
export { FormField } from "./form-field";
|
|
5
|
+
export { LoadingSpinner } from "./loading-spinner";
|
|
6
|
+
export { OAuthButtons } from "./oauth-buttons";
|
|
7
|
+
export { PasswordInput } from "./password-input";
|
|
8
|
+
export { SuccessMessage } from "./success-message";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-spinner.d.ts","sourceRoot":"","sources":["../../components/loading-spinner.tsx"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,YAAY,EAAE,SAAqB,GACpC,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,2CAQA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../utils";
|
|
4
|
+
export function LoadingSpinner({ className, "aria-label": ariaLabel = "Loading", }) {
|
|
5
|
+
return (_jsx("span", { role: "status", "aria-label": ariaLabel, className: cn("inline-block size-5 animate-spin rounded-full border-2 border-current border-t-transparent", className) }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OAuthProvider } from "../types";
|
|
2
|
+
export declare function OAuthButtons({ providers, loadingProvider, onSignIn, className, }: {
|
|
3
|
+
providers: {
|
|
4
|
+
provider: OAuthProvider;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
}[];
|
|
7
|
+
loadingProvider: OAuthProvider | null;
|
|
8
|
+
onSignIn: (provider: OAuthProvider) => void | Promise<void>;
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
//# sourceMappingURL=oauth-buttons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-buttons.d.ts","sourceRoot":"","sources":["../../components/oauth-buttons.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAO9C,wBAAgB,YAAY,CAAC,EAC3B,SAAS,EACT,eAAe,EACf,QAAQ,EACR,SAAS,GACV,EAAE;IACD,SAAS,EAAE;QAAE,QAAQ,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;IAC3D,eAAe,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,kDA0BA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Button } from "./ui/button";
|
|
4
|
+
import { cn } from "../utils";
|
|
5
|
+
const providerLabels = {
|
|
6
|
+
google: "Continue with Google",
|
|
7
|
+
apple: "Continue with Apple",
|
|
8
|
+
};
|
|
9
|
+
export function OAuthButtons({ providers, loadingProvider, onSignIn, className, }) {
|
|
10
|
+
const enabled = providers.filter((p) => p.enabled);
|
|
11
|
+
if (enabled.length === 0)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsx("div", { className: cn("space-y-2", className), children: enabled.map(({ provider }) => (_jsx(Button, { type: "button", variant: "outline", className: "w-full", disabled: !!loadingProvider, onClick: () => onSignIn(provider), "aria-busy": loadingProvider === provider, children: loadingProvider === provider ? (_jsx("span", { className: "inline-block size-4 animate-spin rounded-full border-2 border-current border-t-transparent" })) : (providerLabels[provider]) }, provider))) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Input } from "./ui/input";
|
|
3
|
+
export interface PasswordInputProps extends Omit<React.ComponentProps<typeof Input>, "type"> {
|
|
4
|
+
showStrength?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare const PasswordInput: React.ForwardRefExoticComponent<Omit<PasswordInputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
7
|
+
export { PasswordInput };
|
|
8
|
+
//# sourceMappingURL=password-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-input.d.ts","sourceRoot":"","sources":["../../components/password-input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAanC,MAAM,WAAW,kBACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,KAAK,CAAC,EAAE,MAAM,CAAC;IACxD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,QAAA,MAAM,aAAa,0GAoElB,CAAC;AAGF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Input } from "./ui/input";
|
|
5
|
+
import { Button } from "./ui/button";
|
|
6
|
+
import { cn } from "../utils";
|
|
7
|
+
function getStrength(value) {
|
|
8
|
+
if (!value)
|
|
9
|
+
return 0;
|
|
10
|
+
let s = 0;
|
|
11
|
+
if (value.length >= 8)
|
|
12
|
+
s++;
|
|
13
|
+
if (value.length >= 12)
|
|
14
|
+
s++;
|
|
15
|
+
if (/[A-Z]/.test(value) && /[a-z]/.test(value) && /\d/.test(value))
|
|
16
|
+
s++;
|
|
17
|
+
return Math.min(s, 3);
|
|
18
|
+
}
|
|
19
|
+
const PasswordInput = React.forwardRef(({ className, showStrength = false, ...props }, ref) => {
|
|
20
|
+
const [show, setShow] = React.useState(false);
|
|
21
|
+
const [value, setValue] = React.useState("");
|
|
22
|
+
const id = React.useId();
|
|
23
|
+
const strength = showStrength ? getStrength(value) : 0;
|
|
24
|
+
return (_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "relative", children: [_jsx(Input, { ref: ref, type: show ? "text" : "password", autoComplete: "current-password", "aria-describedby": showStrength ? `${id}-strength` : undefined, className: cn("pr-10", className), ...props, value: props.value ?? value, onChange: (e) => {
|
|
25
|
+
setValue(e.target.value);
|
|
26
|
+
props.onChange?.(e);
|
|
27
|
+
} }), _jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent", "aria-label": show ? "Hide password" : "Show password", "aria-pressed": show, onClick: () => setShow((p) => !p), tabIndex: -1, children: _jsx("span", { className: "text-xs font-medium", "aria-hidden": "true", children: show ? "Hide" : "Show" }) })] }), showStrength && value && (_jsx("div", { id: `${id}-strength`, role: "progressbar", "aria-valuenow": strength, "aria-valuemin": 0, "aria-valuemax": 3, "aria-label": "Password strength", className: "flex gap-1", children: [1, 2, 3].map((i) => (_jsx("span", { className: cn("h-1 flex-1 rounded-full", i <= strength
|
|
28
|
+
? strength === 1
|
|
29
|
+
? "bg-destructive"
|
|
30
|
+
: strength === 2
|
|
31
|
+
? "bg-amber-500"
|
|
32
|
+
: "bg-green-500"
|
|
33
|
+
: "bg-muted") }, i))) }))] }));
|
|
34
|
+
});
|
|
35
|
+
PasswordInput.displayName = "PasswordInput";
|
|
36
|
+
export { PasswordInput };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"success-message.d.ts","sourceRoot":"","sources":["../../components/success-message.tsx"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,SAAS,EACT,EAAE,GACH,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,kDAWA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../utils";
|
|
4
|
+
export function SuccessMessage({ children, className, id, }) {
|
|
5
|
+
if (!children)
|
|
6
|
+
return null;
|
|
7
|
+
return (_jsx("p", { id: id, role: "status", className: cn("text-sm text-green-600 dark:text-green-400", className), children: children }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
export { Button, buttonVariants };
|
|
12
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,QAAA,MAAM,cAAc;;;8EAwBnB,CAAC;AAEF,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,MAAM,uFAWX,CAAC;AAGF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../utils";
|
|
6
|
+
const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
10
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
11
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
12
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
13
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
14
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
default: "h-10 px-4 py-2",
|
|
18
|
+
sm: "h-9 rounded-md px-3",
|
|
19
|
+
lg: "h-11 rounded-md px-8",
|
|
20
|
+
icon: "h-10 w-10",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: "default",
|
|
25
|
+
size: "default",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const Button = React.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
29
|
+
const Comp = asChild ? Slot : "button";
|
|
30
|
+
return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, className })), ref: ref, ...props }));
|
|
31
|
+
});
|
|
32
|
+
Button.displayName = "Button";
|
|
33
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const Card: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
3
|
+
declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
5
|
+
declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
6
|
+
declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
9
|
+
//# sourceMappingURL=card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../components/ui/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,QAAA,MAAM,IAAI,6GAYR,CAAC;AAGH,QAAA,MAAM,UAAU,6GASd,CAAC;AAGH,QAAA,MAAM,SAAS,uHASb,CAAC;AAGH,QAAA,MAAM,eAAe,yHASnB,CAAC;AAGH,QAAA,MAAM,WAAW,6GAKf,CAAC;AAGH,QAAA,MAAM,UAAU,6GASd,CAAC;AAGH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils";
|
|
4
|
+
const Card = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("rounded-lg border border-border bg-card text-card-foreground shadow-sm", className), ...props })));
|
|
5
|
+
Card.displayName = "Card";
|
|
6
|
+
const CardHeader = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex flex-col space-y-1.5 p-6", className), ...props })));
|
|
7
|
+
CardHeader.displayName = "CardHeader";
|
|
8
|
+
const CardTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx("h3", { ref: ref, className: cn("text-2xl font-semibold leading-none tracking-tight", className), ...props })));
|
|
9
|
+
CardTitle.displayName = "CardTitle";
|
|
10
|
+
const CardDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx("p", { ref: ref, className: cn("text-sm text-muted-foreground", className), ...props })));
|
|
11
|
+
CardDescription.displayName = "CardDescription";
|
|
12
|
+
const CardContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("p-6 pt-0", className), ...props })));
|
|
13
|
+
CardContent.displayName = "CardContent";
|
|
14
|
+
const CardFooter = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn("flex items-center p-6 pt-0", className), ...props })));
|
|
15
|
+
CardFooter.displayName = "CardFooter";
|
|
16
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare const Input: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
3
|
+
export { Input };
|
|
4
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../components/ui/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,QAAA,MAAM,KAAK,8KAcV,CAAC;AAGF,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils";
|
|
4
|
+
const Input = React.forwardRef(({ className, type, ...props }, ref) => {
|
|
5
|
+
return (_jsx("input", { type: type, className: cn("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className), ref: ref, ...props }));
|
|
6
|
+
});
|
|
7
|
+
Input.displayName = "Input";
|
|
8
|
+
export { Input };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
|
+
import { type VariantProps } from "class-variance-authority";
|
|
4
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & VariantProps<(props?: import("class-variance-authority/types").ClassProp | undefined) => string> & React.RefAttributes<HTMLLabelElement>>;
|
|
5
|
+
export { Label };
|
|
6
|
+
//# sourceMappingURL=label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../components/ui/label.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAOlE,QAAA,MAAM,KAAK,4PAUT,CAAC;AAGH,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../../utils";
|
|
7
|
+
const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
|
|
8
|
+
const Label = React.forwardRef(({ className, ...props }, ref) => (_jsx(LabelPrimitive.Root, { ref: ref, className: cn(labelVariants(), className), ...props })));
|
|
9
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
10
|
+
export { Label };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { AuthUIConfig } from "./types";
|
|
3
|
+
export declare function AuthUIProvider({ config, children, }: {
|
|
4
|
+
config: AuthUIConfig;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function useAuthUIConfig(): AuthUIConfig;
|
|
8
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,2CAMA;AAED,wBAAgB,eAAe,IAAI,YAAY,CAI9C"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
const AuthUIConfigContext = React.createContext(null);
|
|
5
|
+
export function AuthUIProvider({ config, children, }) {
|
|
6
|
+
return (_jsx(AuthUIConfigContext.Provider, { value: config, children: children }));
|
|
7
|
+
}
|
|
8
|
+
export function useAuthUIConfig() {
|
|
9
|
+
const ctx = React.useContext(AuthUIConfigContext);
|
|
10
|
+
if (!ctx)
|
|
11
|
+
throw new Error("useAuthUIConfig must be used within AuthUIProvider");
|
|
12
|
+
return ctx;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AuthError, AuthSession } from "../types";
|
|
2
|
+
type AuthResult = {
|
|
3
|
+
success: true;
|
|
4
|
+
} | {
|
|
5
|
+
success: false;
|
|
6
|
+
error: AuthError;
|
|
7
|
+
};
|
|
8
|
+
export declare function useAuth(): {
|
|
9
|
+
login: (email: string, password: string) => Promise<AuthResult>;
|
|
10
|
+
register: (email: string, password: string) => Promise<AuthResult>;
|
|
11
|
+
logout: () => Promise<void>;
|
|
12
|
+
forgotPassword: (email: string) => Promise<AuthResult>;
|
|
13
|
+
resetPassword: (token: string, newPassword: string) => Promise<AuthResult>;
|
|
14
|
+
verifyEmail: (token: string) => Promise<AuthResult>;
|
|
15
|
+
session: AuthSession | null;
|
|
16
|
+
loadSession: () => Promise<AuthSession | null>;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
error: AuthError | null;
|
|
19
|
+
clearError: () => void;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=use-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-auth.d.ts","sourceRoot":"","sources":["../../hooks/use-auth.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvD,KAAK,UAAU,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAE3E,wBAAgB,OAAO;mBAQL,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;sBAqB9C,MAAM,YAAY,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;;4BA4B9C,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;2BAe5B,MAAM,eAAe,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;yBAkBjD,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC;;;;;;EAgC7C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { useAuthUIConfig } from "../context";
|
|
4
|
+
export function useAuth() {
|
|
5
|
+
const { authClient, redirectAfterLogin, redirectAfterRegister, redirectAfterReset } = useAuthUIConfig();
|
|
6
|
+
const [loading, setLoading] = useState(false);
|
|
7
|
+
const [error, setError] = useState(null);
|
|
8
|
+
const [session, setSession] = useState(null);
|
|
9
|
+
const login = useCallback(async (email, password) => {
|
|
10
|
+
setLoading(true);
|
|
11
|
+
setError(null);
|
|
12
|
+
try {
|
|
13
|
+
const result = await authClient.login(email, password);
|
|
14
|
+
if (result.success) {
|
|
15
|
+
if (redirectAfterLogin && typeof window !== "undefined") {
|
|
16
|
+
window.location.href = redirectAfterLogin;
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
setError(result.error);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
setLoading(false);
|
|
25
|
+
}
|
|
26
|
+
}, [authClient, redirectAfterLogin]);
|
|
27
|
+
const register = useCallback(async (email, password) => {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
setError(null);
|
|
30
|
+
try {
|
|
31
|
+
const result = await authClient.register(email, password);
|
|
32
|
+
if (result.success && redirectAfterRegister && typeof window !== "undefined") {
|
|
33
|
+
window.location.href = redirectAfterRegister;
|
|
34
|
+
}
|
|
35
|
+
if (!result.success)
|
|
36
|
+
setError(result.error);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}, [authClient, redirectAfterRegister]);
|
|
43
|
+
const logout = useCallback(async () => {
|
|
44
|
+
setLoading(true);
|
|
45
|
+
try {
|
|
46
|
+
await authClient.logout();
|
|
47
|
+
setSession(null);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}
|
|
52
|
+
}, [authClient]);
|
|
53
|
+
const forgotPassword = useCallback(async (email) => {
|
|
54
|
+
setLoading(true);
|
|
55
|
+
setError(null);
|
|
56
|
+
try {
|
|
57
|
+
const result = await authClient.forgotPassword(email);
|
|
58
|
+
if (!result.success)
|
|
59
|
+
setError(result.error);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
setLoading(false);
|
|
64
|
+
}
|
|
65
|
+
}, [authClient]);
|
|
66
|
+
const resetPassword = useCallback(async (token, newPassword) => {
|
|
67
|
+
setLoading(true);
|
|
68
|
+
setError(null);
|
|
69
|
+
try {
|
|
70
|
+
const result = await authClient.resetPassword(token, newPassword);
|
|
71
|
+
if (result.success && redirectAfterReset && typeof window !== "undefined") {
|
|
72
|
+
window.location.href = redirectAfterReset;
|
|
73
|
+
}
|
|
74
|
+
if (!result.success)
|
|
75
|
+
setError(result.error);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
setLoading(false);
|
|
80
|
+
}
|
|
81
|
+
}, [authClient, redirectAfterReset]);
|
|
82
|
+
const verifyEmail = useCallback(async (token) => {
|
|
83
|
+
setLoading(true);
|
|
84
|
+
setError(null);
|
|
85
|
+
try {
|
|
86
|
+
return await authClient.verifyEmail(token);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
setLoading(false);
|
|
90
|
+
}
|
|
91
|
+
}, [authClient]);
|
|
92
|
+
const loadSession = useCallback(async () => {
|
|
93
|
+
if (!authClient.getSession)
|
|
94
|
+
return null;
|
|
95
|
+
const s = await authClient.getSession();
|
|
96
|
+
setSession(s);
|
|
97
|
+
return s;
|
|
98
|
+
}, [authClient]);
|
|
99
|
+
return {
|
|
100
|
+
login,
|
|
101
|
+
register,
|
|
102
|
+
logout,
|
|
103
|
+
forgotPassword,
|
|
104
|
+
resetPassword,
|
|
105
|
+
verifyEmail,
|
|
106
|
+
session,
|
|
107
|
+
loadSession,
|
|
108
|
+
loading,
|
|
109
|
+
error,
|
|
110
|
+
clearError: () => setError(null),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OAuthProvider } from "../types";
|
|
2
|
+
export declare function useOAuth(onRedirect: (provider: OAuthProvider) => string | Promise<string>): {
|
|
3
|
+
signIn: (provider: OAuthProvider) => Promise<void>;
|
|
4
|
+
loadingProvider: OAuthProvider | null;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=use-oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-oauth.d.ts","sourceRoot":"","sources":["../../hooks/use-oauth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;uBAIrE,aAAa;;EAejC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
export function useOAuth(onRedirect) {
|
|
4
|
+
const [loadingProvider, setLoadingProvider] = useState(null);
|
|
5
|
+
const signIn = useCallback(async (provider) => {
|
|
6
|
+
setLoadingProvider(provider);
|
|
7
|
+
try {
|
|
8
|
+
const url = await onRedirect(provider);
|
|
9
|
+
if (typeof window !== "undefined" && url) {
|
|
10
|
+
window.location.href = url;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
setLoadingProvider(null);
|
|
15
|
+
}
|
|
16
|
+
}, [onRedirect]);
|
|
17
|
+
return { signIn, loadingProvider };
|
|
18
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AuthUIProvider, useAuthUIConfig } from "./context";
|
|
2
|
+
export { AuthCard, AuthForm, ErrorMessage, FormField, LoadingSpinner, OAuthButtons, PasswordInput, SuccessMessage, } from "./components";
|
|
3
|
+
export { useAuth } from "./hooks/use-auth";
|
|
4
|
+
export { useOAuth } from "./hooks/use-oauth";
|
|
5
|
+
export { LoginPage, RegisterPage, ForgotPasswordPage, ResetPasswordPage, VerifyEmailPage, } from "./pages";
|
|
6
|
+
export type { AuthClient, AuthError, AuthFormState, AuthSession, AuthUIConfig, OAuthProvider, } from "./types";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,cAAc,EACd,YAAY,EACZ,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACb,WAAW,EACX,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AuthUIProvider, useAuthUIConfig } from "./context";
|
|
2
|
+
export { AuthCard, AuthForm, ErrorMessage, FormField, LoadingSpinner, OAuthButtons, PasswordInput, SuccessMessage, } from "./components";
|
|
3
|
+
export { useAuth } from "./hooks/use-auth";
|
|
4
|
+
export { useOAuth } from "./hooks/use-oauth";
|
|
5
|
+
export { LoginPage, RegisterPage, ForgotPasswordPage, ResetPasswordPage, VerifyEmailPage, } from "./pages";
|