@githat/nextjs 0.4.0 → 0.4.1
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/index.d.mts +73 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.js +475 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +471 -1
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +50 -1
- package/dist/server.d.ts +50 -1
- package/dist/server.js +19 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +17 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21,15 +21,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var src_exports = {};
|
|
23
23
|
__export(src_exports, {
|
|
24
|
+
ChangePasswordForm: () => ChangePasswordForm,
|
|
25
|
+
ForgotPasswordForm: () => ForgotPasswordForm,
|
|
24
26
|
GitHatProvider: () => GitHatProvider,
|
|
25
27
|
OrgSwitcher: () => OrgSwitcher,
|
|
26
28
|
ProtectedRoute: () => ProtectedRoute,
|
|
29
|
+
ResetPasswordForm: () => ResetPasswordForm,
|
|
27
30
|
SignInButton: () => SignInButton,
|
|
28
31
|
SignInForm: () => SignInForm,
|
|
29
32
|
SignUpButton: () => SignUpButton,
|
|
30
33
|
SignUpForm: () => SignUpForm,
|
|
31
34
|
UserButton: () => UserButton,
|
|
32
35
|
VerifiedBadge: () => VerifiedBadge,
|
|
36
|
+
VerifyEmailStatus: () => VerifyEmailStatus,
|
|
33
37
|
useAuth: () => useAuth,
|
|
34
38
|
useData: () => useData,
|
|
35
39
|
useGitHat: () => useGitHat
|
|
@@ -359,13 +363,90 @@ function useGitHat() {
|
|
|
359
363
|
},
|
|
360
364
|
[client, ctx.org?.id]
|
|
361
365
|
);
|
|
366
|
+
const forgotPassword = (0, import_react2.useCallback)(
|
|
367
|
+
async (email) => {
|
|
368
|
+
const response = await fetch(`${ctx.config.apiUrl}/auth/forgot-password`, {
|
|
369
|
+
method: "POST",
|
|
370
|
+
headers: { "Content-Type": "application/json" },
|
|
371
|
+
body: JSON.stringify({ email })
|
|
372
|
+
});
|
|
373
|
+
if (!response.ok) {
|
|
374
|
+
const error = await response.json().catch(() => ({}));
|
|
375
|
+
throw new Error(error.message || "Failed to send reset email");
|
|
376
|
+
}
|
|
377
|
+
return { success: true };
|
|
378
|
+
},
|
|
379
|
+
[ctx.config.apiUrl]
|
|
380
|
+
);
|
|
381
|
+
const resetPassword = (0, import_react2.useCallback)(
|
|
382
|
+
async (token, newPassword) => {
|
|
383
|
+
const response = await fetch(`${ctx.config.apiUrl}/auth/reset-password`, {
|
|
384
|
+
method: "POST",
|
|
385
|
+
headers: { "Content-Type": "application/json" },
|
|
386
|
+
body: JSON.stringify({ token, password: newPassword })
|
|
387
|
+
});
|
|
388
|
+
if (!response.ok) {
|
|
389
|
+
const error = await response.json().catch(() => ({}));
|
|
390
|
+
throw new Error(error.message || "Failed to reset password");
|
|
391
|
+
}
|
|
392
|
+
return { success: true };
|
|
393
|
+
},
|
|
394
|
+
[ctx.config.apiUrl]
|
|
395
|
+
);
|
|
396
|
+
const changePassword = (0, import_react2.useCallback)(
|
|
397
|
+
async (currentPassword, newPassword) => {
|
|
398
|
+
await client.fetchApi("/auth/change-password", {
|
|
399
|
+
method: "POST",
|
|
400
|
+
body: JSON.stringify({ currentPassword, newPassword })
|
|
401
|
+
});
|
|
402
|
+
return { success: true };
|
|
403
|
+
},
|
|
404
|
+
[client]
|
|
405
|
+
);
|
|
406
|
+
const verifyEmail = (0, import_react2.useCallback)(
|
|
407
|
+
async (token) => {
|
|
408
|
+
const response = await fetch(`${ctx.config.apiUrl}/auth/verify-email`, {
|
|
409
|
+
method: "POST",
|
|
410
|
+
headers: { "Content-Type": "application/json" },
|
|
411
|
+
body: JSON.stringify({ token })
|
|
412
|
+
});
|
|
413
|
+
if (!response.ok) {
|
|
414
|
+
const error = await response.json().catch(() => ({}));
|
|
415
|
+
throw new Error(error.message || "Failed to verify email");
|
|
416
|
+
}
|
|
417
|
+
return { success: true };
|
|
418
|
+
},
|
|
419
|
+
[ctx.config.apiUrl]
|
|
420
|
+
);
|
|
421
|
+
const resendVerificationEmail = (0, import_react2.useCallback)(
|
|
422
|
+
async (email) => {
|
|
423
|
+
const response = await fetch(`${ctx.config.apiUrl}/auth/resend-verification`, {
|
|
424
|
+
method: "POST",
|
|
425
|
+
headers: { "Content-Type": "application/json" },
|
|
426
|
+
body: JSON.stringify({ email })
|
|
427
|
+
});
|
|
428
|
+
if (!response.ok) {
|
|
429
|
+
const error = await response.json().catch(() => ({}));
|
|
430
|
+
throw new Error(error.message || "Failed to resend verification email");
|
|
431
|
+
}
|
|
432
|
+
return { success: true };
|
|
433
|
+
},
|
|
434
|
+
[ctx.config.apiUrl]
|
|
435
|
+
);
|
|
362
436
|
return {
|
|
363
437
|
fetch: client.fetchApi,
|
|
364
438
|
getUserOrgs: () => client.fetchApi("/user/orgs"),
|
|
365
439
|
verifyMCP: (domain) => client.fetchApi(`/verify/mcp/${domain}`),
|
|
366
440
|
verifyAgent: (wallet) => client.fetchApi(`/verify/agent/${wallet}`),
|
|
367
441
|
getOrgMetadata,
|
|
368
|
-
updateOrgMetadata
|
|
442
|
+
updateOrgMetadata,
|
|
443
|
+
// Password management
|
|
444
|
+
forgotPassword,
|
|
445
|
+
resetPassword,
|
|
446
|
+
changePassword,
|
|
447
|
+
// Email verification
|
|
448
|
+
verifyEmail,
|
|
449
|
+
resendVerificationEmail
|
|
369
450
|
};
|
|
370
451
|
}
|
|
371
452
|
|
|
@@ -808,17 +889,410 @@ function ProtectedRoute({ children, fallback }) {
|
|
|
808
889
|
}
|
|
809
890
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children });
|
|
810
891
|
}
|
|
892
|
+
|
|
893
|
+
// src/components/ForgotPasswordForm.tsx
|
|
894
|
+
var import_react11 = require("react");
|
|
895
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
896
|
+
function ForgotPasswordForm({
|
|
897
|
+
onSuccess,
|
|
898
|
+
onError,
|
|
899
|
+
signInUrl = "/sign-in"
|
|
900
|
+
}) {
|
|
901
|
+
const { forgotPassword } = useGitHat();
|
|
902
|
+
const [email, setEmail] = (0, import_react11.useState)("");
|
|
903
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
|
|
904
|
+
const [sent, setSent] = (0, import_react11.useState)(false);
|
|
905
|
+
const [error, setError] = (0, import_react11.useState)("");
|
|
906
|
+
const emailValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
907
|
+
const handleSubmit = async (e) => {
|
|
908
|
+
e.preventDefault();
|
|
909
|
+
if (!emailValid) {
|
|
910
|
+
setError("Please enter a valid email address");
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
setIsLoading(true);
|
|
914
|
+
setError("");
|
|
915
|
+
try {
|
|
916
|
+
await forgotPassword(email);
|
|
917
|
+
setSent(true);
|
|
918
|
+
onSuccess?.(email);
|
|
919
|
+
} catch (err) {
|
|
920
|
+
const message = err instanceof Error ? err.message : "Failed to send reset email";
|
|
921
|
+
setError(message);
|
|
922
|
+
onError?.(err instanceof Error ? err : new Error(message));
|
|
923
|
+
} finally {
|
|
924
|
+
setIsLoading(false);
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
if (sent) {
|
|
928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "githat-form-container", children: [
|
|
929
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "githat-form-header", children: [
|
|
930
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: "githat-form-title", children: "Check your email" }),
|
|
931
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "githat-form-subtitle", children: [
|
|
932
|
+
"We sent a password reset link to ",
|
|
933
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("strong", { children: email })
|
|
934
|
+
] })
|
|
935
|
+
] }),
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { href: signInUrl, className: "githat-link", children: "Back to sign in" }),
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "githat-powered-by", children: [
|
|
938
|
+
"Secured by ",
|
|
939
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("strong", { children: "GitHat" })
|
|
940
|
+
] })
|
|
941
|
+
] });
|
|
942
|
+
}
|
|
943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "githat-form-container", children: [
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "githat-form-header", children: [
|
|
945
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: "githat-form-title", children: "Forgot password" }),
|
|
946
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "githat-form-subtitle", children: "Enter your email and we'll send you a reset link" })
|
|
947
|
+
] }),
|
|
948
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "githat-alert githat-alert-error", role: "alert", "aria-live": "polite", children: error }),
|
|
949
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { onSubmit: handleSubmit, className: "githat-form", "aria-label": "Forgot password form", children: [
|
|
950
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "githat-field", children: [
|
|
951
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { className: "githat-label", htmlFor: "githat-forgot-email", children: "Email" }),
|
|
952
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
953
|
+
"input",
|
|
954
|
+
{
|
|
955
|
+
id: "githat-forgot-email",
|
|
956
|
+
className: "githat-input",
|
|
957
|
+
type: "email",
|
|
958
|
+
value: email,
|
|
959
|
+
onChange: (e) => setEmail(e.target.value),
|
|
960
|
+
placeholder: "you@example.com",
|
|
961
|
+
autoComplete: "email",
|
|
962
|
+
disabled: isLoading,
|
|
963
|
+
required: true
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
] }),
|
|
967
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
968
|
+
"button",
|
|
969
|
+
{
|
|
970
|
+
type: "submit",
|
|
971
|
+
className: "githat-button githat-button-primary",
|
|
972
|
+
disabled: isLoading || !email || email.length > 0 && !emailValid,
|
|
973
|
+
children: isLoading ? "Sending..." : "Send reset link"
|
|
974
|
+
}
|
|
975
|
+
)
|
|
976
|
+
] }),
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "githat-form-footer", children: [
|
|
978
|
+
"Remember your password? ",
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("a", { href: signInUrl, className: "githat-link", children: "Sign in" })
|
|
980
|
+
] }),
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "githat-powered-by", children: [
|
|
982
|
+
"Secured by ",
|
|
983
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("strong", { children: "GitHat" })
|
|
984
|
+
] })
|
|
985
|
+
] });
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/components/ResetPasswordForm.tsx
|
|
989
|
+
var import_react12 = require("react");
|
|
990
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
991
|
+
function ResetPasswordForm({
|
|
992
|
+
token,
|
|
993
|
+
onSuccess,
|
|
994
|
+
onError,
|
|
995
|
+
signInUrl = "/sign-in",
|
|
996
|
+
minPasswordLength = 8
|
|
997
|
+
}) {
|
|
998
|
+
const { resetPassword } = useGitHat();
|
|
999
|
+
const [password, setPassword] = (0, import_react12.useState)("");
|
|
1000
|
+
const [confirm, setConfirm] = (0, import_react12.useState)("");
|
|
1001
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
1002
|
+
const [success, setSuccess] = (0, import_react12.useState)(false);
|
|
1003
|
+
const [error, setError] = (0, import_react12.useState)("");
|
|
1004
|
+
const handleSubmit = async (e) => {
|
|
1005
|
+
e.preventDefault();
|
|
1006
|
+
if (password !== confirm) {
|
|
1007
|
+
setError("Passwords do not match");
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
if (password.length < minPasswordLength) {
|
|
1011
|
+
setError(`Password must be at least ${minPasswordLength} characters`);
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
setIsLoading(true);
|
|
1015
|
+
setError("");
|
|
1016
|
+
try {
|
|
1017
|
+
await resetPassword(token, password);
|
|
1018
|
+
setSuccess(true);
|
|
1019
|
+
onSuccess?.();
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
const message = err instanceof Error ? err.message : "Failed to reset password";
|
|
1022
|
+
setError(message);
|
|
1023
|
+
onError?.(err instanceof Error ? err : new Error(message));
|
|
1024
|
+
} finally {
|
|
1025
|
+
setIsLoading(false);
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
if (success) {
|
|
1029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "githat-form-container", children: [
|
|
1030
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "githat-form-header", children: [
|
|
1031
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: "githat-form-title", children: "Password reset!" }),
|
|
1032
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "githat-form-subtitle", children: "Your password has been successfully reset." })
|
|
1033
|
+
] }),
|
|
1034
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("a", { href: signInUrl, className: "githat-button githat-button-primary", style: { display: "block", textAlign: "center", textDecoration: "none" }, children: "Sign in" }),
|
|
1035
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "githat-powered-by", children: [
|
|
1036
|
+
"Secured by ",
|
|
1037
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("strong", { children: "GitHat" })
|
|
1038
|
+
] })
|
|
1039
|
+
] });
|
|
1040
|
+
}
|
|
1041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "githat-form-container", children: [
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "githat-form-header", children: [
|
|
1043
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: "githat-form-title", children: "Reset password" }),
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "githat-form-subtitle", children: "Enter your new password" })
|
|
1045
|
+
] }),
|
|
1046
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "githat-alert githat-alert-error", role: "alert", "aria-live": "polite", children: error }),
|
|
1047
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("form", { onSubmit: handleSubmit, className: "githat-form", "aria-label": "Reset password form", children: [
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "githat-field", children: [
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("label", { className: "githat-label", htmlFor: "githat-reset-password", children: "New password" }),
|
|
1050
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1051
|
+
"input",
|
|
1052
|
+
{
|
|
1053
|
+
id: "githat-reset-password",
|
|
1054
|
+
className: "githat-input",
|
|
1055
|
+
type: "password",
|
|
1056
|
+
value: password,
|
|
1057
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1058
|
+
placeholder: "Enter new password",
|
|
1059
|
+
autoComplete: "new-password",
|
|
1060
|
+
disabled: isLoading,
|
|
1061
|
+
required: true,
|
|
1062
|
+
minLength: minPasswordLength
|
|
1063
|
+
}
|
|
1064
|
+
)
|
|
1065
|
+
] }),
|
|
1066
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "githat-field", children: [
|
|
1067
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("label", { className: "githat-label", htmlFor: "githat-reset-confirm", children: "Confirm password" }),
|
|
1068
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1069
|
+
"input",
|
|
1070
|
+
{
|
|
1071
|
+
id: "githat-reset-confirm",
|
|
1072
|
+
className: "githat-input",
|
|
1073
|
+
type: "password",
|
|
1074
|
+
value: confirm,
|
|
1075
|
+
onChange: (e) => setConfirm(e.target.value),
|
|
1076
|
+
placeholder: "Confirm new password",
|
|
1077
|
+
autoComplete: "new-password",
|
|
1078
|
+
disabled: isLoading,
|
|
1079
|
+
required: true
|
|
1080
|
+
}
|
|
1081
|
+
)
|
|
1082
|
+
] }),
|
|
1083
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1084
|
+
"button",
|
|
1085
|
+
{
|
|
1086
|
+
type: "submit",
|
|
1087
|
+
className: "githat-button githat-button-primary",
|
|
1088
|
+
disabled: isLoading || !password || !confirm,
|
|
1089
|
+
children: isLoading ? "Resetting..." : "Reset password"
|
|
1090
|
+
}
|
|
1091
|
+
)
|
|
1092
|
+
] }),
|
|
1093
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "githat-powered-by", children: [
|
|
1094
|
+
"Secured by ",
|
|
1095
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("strong", { children: "GitHat" })
|
|
1096
|
+
] })
|
|
1097
|
+
] });
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// src/components/VerifyEmailStatus.tsx
|
|
1101
|
+
var import_react13 = require("react");
|
|
1102
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1103
|
+
function VerifyEmailStatus({
|
|
1104
|
+
token,
|
|
1105
|
+
onSuccess,
|
|
1106
|
+
onError,
|
|
1107
|
+
signInUrl = "/sign-in",
|
|
1108
|
+
redirectDelay = 3e3
|
|
1109
|
+
}) {
|
|
1110
|
+
const { verifyEmail } = useGitHat();
|
|
1111
|
+
const [status, setStatus] = (0, import_react13.useState)("loading");
|
|
1112
|
+
const [error, setError] = (0, import_react13.useState)("");
|
|
1113
|
+
(0, import_react13.useEffect)(() => {
|
|
1114
|
+
if (!token) {
|
|
1115
|
+
setStatus("error");
|
|
1116
|
+
setError("Missing verification token");
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
verifyEmail(token).then(() => {
|
|
1120
|
+
setStatus("success");
|
|
1121
|
+
onSuccess?.();
|
|
1122
|
+
if (signInUrl && redirectDelay > 0) {
|
|
1123
|
+
setTimeout(() => {
|
|
1124
|
+
window.location.href = signInUrl;
|
|
1125
|
+
}, redirectDelay);
|
|
1126
|
+
}
|
|
1127
|
+
}).catch((err) => {
|
|
1128
|
+
setStatus("error");
|
|
1129
|
+
const message = err instanceof Error ? err.message : "Verification failed";
|
|
1130
|
+
setError(message);
|
|
1131
|
+
onError?.(err instanceof Error ? err : new Error(message));
|
|
1132
|
+
});
|
|
1133
|
+
}, [token, verifyEmail, onSuccess, onError, signInUrl, redirectDelay]);
|
|
1134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "githat-form-container", children: [
|
|
1135
|
+
status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "githat-form-header", children: [
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "githat-form-title", children: "Verifying email..." }),
|
|
1137
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "githat-form-subtitle", children: "Please wait while we verify your email address." })
|
|
1138
|
+
] }),
|
|
1139
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "githat-form-header", children: [
|
|
1141
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "githat-form-title", children: "Email verified!" }),
|
|
1142
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "githat-form-subtitle", children: "Your email has been successfully verified. Redirecting to sign in..." })
|
|
1143
|
+
] }),
|
|
1144
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", { href: signInUrl, className: "githat-button githat-button-primary", style: { display: "block", textAlign: "center", textDecoration: "none" }, children: "Sign in now" })
|
|
1145
|
+
] }),
|
|
1146
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
1147
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "githat-form-header", children: [
|
|
1148
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "githat-form-title", children: "Verification failed" }),
|
|
1149
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "githat-form-subtitle", children: error })
|
|
1150
|
+
] }),
|
|
1151
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "githat-form-footer", children: [
|
|
1152
|
+
"The link may have expired. ",
|
|
1153
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", { href: "/sign-up", className: "githat-link", children: "Try signing up again" })
|
|
1154
|
+
] })
|
|
1155
|
+
] }),
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "githat-powered-by", children: [
|
|
1157
|
+
"Secured by ",
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("strong", { children: "GitHat" })
|
|
1159
|
+
] })
|
|
1160
|
+
] });
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// src/components/ChangePasswordForm.tsx
|
|
1164
|
+
var import_react14 = require("react");
|
|
1165
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1166
|
+
function ChangePasswordForm({
|
|
1167
|
+
onSuccess,
|
|
1168
|
+
onError,
|
|
1169
|
+
minPasswordLength = 8
|
|
1170
|
+
}) {
|
|
1171
|
+
const { changePassword } = useGitHat();
|
|
1172
|
+
const [current, setCurrent] = (0, import_react14.useState)("");
|
|
1173
|
+
const [newPass, setNewPass] = (0, import_react14.useState)("");
|
|
1174
|
+
const [confirm, setConfirm] = (0, import_react14.useState)("");
|
|
1175
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
|
|
1176
|
+
const [error, setError] = (0, import_react14.useState)("");
|
|
1177
|
+
const [success, setSuccess] = (0, import_react14.useState)(false);
|
|
1178
|
+
const handleSubmit = async (e) => {
|
|
1179
|
+
e.preventDefault();
|
|
1180
|
+
if (newPass !== confirm) {
|
|
1181
|
+
setError("Passwords do not match");
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
if (newPass.length < minPasswordLength) {
|
|
1185
|
+
setError(`Password must be at least ${minPasswordLength} characters`);
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
setIsLoading(true);
|
|
1189
|
+
setError("");
|
|
1190
|
+
try {
|
|
1191
|
+
await changePassword(current, newPass);
|
|
1192
|
+
setSuccess(true);
|
|
1193
|
+
setCurrent("");
|
|
1194
|
+
setNewPass("");
|
|
1195
|
+
setConfirm("");
|
|
1196
|
+
onSuccess?.();
|
|
1197
|
+
} catch (err) {
|
|
1198
|
+
const message = err instanceof Error ? err.message : "Failed to change password";
|
|
1199
|
+
setError(message);
|
|
1200
|
+
onError?.(err instanceof Error ? err : new Error(message));
|
|
1201
|
+
} finally {
|
|
1202
|
+
setIsLoading(false);
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "githat-form-container", children: [
|
|
1206
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "githat-form-header", children: [
|
|
1207
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { className: "githat-form-title", children: "Change password" }),
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "githat-form-subtitle", children: "Update your account password" })
|
|
1209
|
+
] }),
|
|
1210
|
+
success && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "githat-alert githat-alert-success", role: "status", "aria-live": "polite", children: "Password changed successfully!" }),
|
|
1211
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "githat-alert githat-alert-error", role: "alert", "aria-live": "polite", children: error }),
|
|
1212
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("form", { onSubmit: handleSubmit, className: "githat-form", "aria-label": "Change password form", children: [
|
|
1213
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "githat-field", children: [
|
|
1214
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "githat-label", htmlFor: "githat-change-current", children: "Current password" }),
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1216
|
+
"input",
|
|
1217
|
+
{
|
|
1218
|
+
id: "githat-change-current",
|
|
1219
|
+
className: "githat-input",
|
|
1220
|
+
type: "password",
|
|
1221
|
+
value: current,
|
|
1222
|
+
onChange: (e) => setCurrent(e.target.value),
|
|
1223
|
+
placeholder: "Enter current password",
|
|
1224
|
+
autoComplete: "current-password",
|
|
1225
|
+
disabled: isLoading,
|
|
1226
|
+
required: true
|
|
1227
|
+
}
|
|
1228
|
+
)
|
|
1229
|
+
] }),
|
|
1230
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "githat-field", children: [
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "githat-label", htmlFor: "githat-change-new", children: "New password" }),
|
|
1232
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1233
|
+
"input",
|
|
1234
|
+
{
|
|
1235
|
+
id: "githat-change-new",
|
|
1236
|
+
className: "githat-input",
|
|
1237
|
+
type: "password",
|
|
1238
|
+
value: newPass,
|
|
1239
|
+
onChange: (e) => setNewPass(e.target.value),
|
|
1240
|
+
placeholder: "Enter new password",
|
|
1241
|
+
autoComplete: "new-password",
|
|
1242
|
+
disabled: isLoading,
|
|
1243
|
+
required: true,
|
|
1244
|
+
minLength: minPasswordLength
|
|
1245
|
+
}
|
|
1246
|
+
)
|
|
1247
|
+
] }),
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "githat-field", children: [
|
|
1249
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "githat-label", htmlFor: "githat-change-confirm", children: "Confirm new password" }),
|
|
1250
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1251
|
+
"input",
|
|
1252
|
+
{
|
|
1253
|
+
id: "githat-change-confirm",
|
|
1254
|
+
className: "githat-input",
|
|
1255
|
+
type: "password",
|
|
1256
|
+
value: confirm,
|
|
1257
|
+
onChange: (e) => setConfirm(e.target.value),
|
|
1258
|
+
placeholder: "Confirm new password",
|
|
1259
|
+
autoComplete: "new-password",
|
|
1260
|
+
disabled: isLoading,
|
|
1261
|
+
required: true
|
|
1262
|
+
}
|
|
1263
|
+
)
|
|
1264
|
+
] }),
|
|
1265
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1266
|
+
"button",
|
|
1267
|
+
{
|
|
1268
|
+
type: "submit",
|
|
1269
|
+
className: "githat-button githat-button-primary",
|
|
1270
|
+
disabled: isLoading || !current || !newPass || !confirm,
|
|
1271
|
+
children: isLoading ? "Changing..." : "Change password"
|
|
1272
|
+
}
|
|
1273
|
+
)
|
|
1274
|
+
] }),
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "githat-powered-by", children: [
|
|
1276
|
+
"Secured by ",
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("strong", { children: "GitHat" })
|
|
1278
|
+
] })
|
|
1279
|
+
] });
|
|
1280
|
+
}
|
|
811
1281
|
// Annotate the CommonJS export names for ESM import in node:
|
|
812
1282
|
0 && (module.exports = {
|
|
1283
|
+
ChangePasswordForm,
|
|
1284
|
+
ForgotPasswordForm,
|
|
813
1285
|
GitHatProvider,
|
|
814
1286
|
OrgSwitcher,
|
|
815
1287
|
ProtectedRoute,
|
|
1288
|
+
ResetPasswordForm,
|
|
816
1289
|
SignInButton,
|
|
817
1290
|
SignInForm,
|
|
818
1291
|
SignUpButton,
|
|
819
1292
|
SignUpForm,
|
|
820
1293
|
UserButton,
|
|
821
1294
|
VerifiedBadge,
|
|
1295
|
+
VerifyEmailStatus,
|
|
822
1296
|
useAuth,
|
|
823
1297
|
useData,
|
|
824
1298
|
useGitHat
|