nucleus-core-ts 0.8.47 → 0.8.48
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/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.d.ts +1 -1
- package/dist/fe/components/MagicLinkVerifyPage/components/MagicLinkVerifyPage.js +48 -5
- package/dist/fe/components/MagicLinkVerifyPage/store.d.ts +1 -1
- package/dist/fe/components/MagicLinkVerifyPage/theme.d.ts +7 -0
- package/dist/fe/components/MagicLinkVerifyPage/theme.js +7 -0
- package/dist/fe/components/MagicLinkVerifyPage/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import type { MagicLinkVerifyPageConfig } from "../types";
|
|
3
|
-
export declare function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, onBackToLogin, backToLoginHref, redirectDelay, className, texts, }: MagicLinkVerifyPageConfig): ReactElement;
|
|
3
|
+
export declare function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, onBackToLogin, backToLoginHref, redirectDelay, requireConfirmation, className, texts, }: MagicLinkVerifyPageConfig): ReactElement;
|
|
4
4
|
//# sourceMappingURL=MagicLinkVerifyPage.d.ts.map
|
|
@@ -23,13 +23,13 @@ function parseErrorMessage(error, defaultMsg) {
|
|
|
23
23
|
return error.message;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, onBackToLogin, backToLoginHref, redirectDelay = 2000, className, texts }) {
|
|
26
|
+
export function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, onBackToLogin, backToLoginHref, redirectDelay = 2000, requireConfirmation = false, className, texts }) {
|
|
27
27
|
const theme = magicLinkVerifyPageTheme;
|
|
28
28
|
const containerRef = useRef(null);
|
|
29
29
|
const cardRef = useRef(null);
|
|
30
30
|
const hasVerified = useRef(false);
|
|
31
31
|
const store = useMagicLinkVerifyStore();
|
|
32
|
-
const
|
|
32
|
+
const doVerify = useEffectEvent((tokenValue)=>{
|
|
33
33
|
if (!tokenValue) {
|
|
34
34
|
store.setStep("error");
|
|
35
35
|
store.setMessage("Invalid magic link. No token provided.");
|
|
@@ -37,6 +37,7 @@ export function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, o
|
|
|
37
37
|
}
|
|
38
38
|
if (hasVerified.current) return;
|
|
39
39
|
hasVerified.current = true;
|
|
40
|
+
store.setStep("verifying");
|
|
40
41
|
verifyAction.start({
|
|
41
42
|
payload: {
|
|
42
43
|
token: tokenValue
|
|
@@ -67,12 +68,20 @@ export function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, o
|
|
|
67
68
|
}
|
|
68
69
|
});
|
|
69
70
|
});
|
|
70
|
-
|
|
71
|
+
const handleConfirmClick = useEffectEvent(()=>{
|
|
71
72
|
if (token) {
|
|
72
|
-
|
|
73
|
-
}
|
|
73
|
+
doVerify(token);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
useEffect(()=>{
|
|
77
|
+
if (!token) {
|
|
74
78
|
store.setStep("error");
|
|
75
79
|
store.setMessage("Invalid magic link. No token provided.");
|
|
80
|
+
} else if (requireConfirmation) {
|
|
81
|
+
store.setStep("ready");
|
|
82
|
+
store.setMessage(texts?.confirmSubtitle || "Click below to verify and sign in securely.");
|
|
83
|
+
} else {
|
|
84
|
+
doVerify(token);
|
|
76
85
|
}
|
|
77
86
|
return ()=>{
|
|
78
87
|
store.reset();
|
|
@@ -112,6 +121,40 @@ export function MagicLinkVerifyPage({ token, verifyAction, onSuccess, onError, o
|
|
|
112
121
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
113
122
|
className: theme.content.wrapper,
|
|
114
123
|
children: [
|
|
124
|
+
store.step === "ready" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
125
|
+
children: [
|
|
126
|
+
/*#__PURE__*/ _jsx("div", {
|
|
127
|
+
className: theme.states.ready.iconWrapper,
|
|
128
|
+
children: /*#__PURE__*/ _jsx("svg", {
|
|
129
|
+
className: theme.states.ready.icon,
|
|
130
|
+
fill: "none",
|
|
131
|
+
stroke: "currentColor",
|
|
132
|
+
viewBox: "0 0 24 24",
|
|
133
|
+
"aria-hidden": "true",
|
|
134
|
+
children: /*#__PURE__*/ _jsx("path", {
|
|
135
|
+
strokeLinecap: "round",
|
|
136
|
+
strokeLinejoin: "round",
|
|
137
|
+
strokeWidth: 2,
|
|
138
|
+
d: "M13 10V3L4 14h7v7l9-11h-7z"
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
143
|
+
className: theme.states.ready.title,
|
|
144
|
+
children: texts?.confirmTitle || "Magic Link Verification"
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ _jsx("p", {
|
|
147
|
+
className: theme.states.ready.subtitle,
|
|
148
|
+
children: store.message
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ _jsx("button", {
|
|
151
|
+
type: "button",
|
|
152
|
+
onClick: handleConfirmClick,
|
|
153
|
+
className: theme.states.ready.button,
|
|
154
|
+
children: texts?.confirmButton || "Verify & Sign In"
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
}),
|
|
115
158
|
store.step === "verifying" && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
116
159
|
children: [
|
|
117
160
|
/*#__PURE__*/ _jsx("div", {
|
|
@@ -30,6 +30,13 @@ export const magicLinkVerifyPageTheme = {
|
|
|
30
30
|
icon: "w-8 h-8 text-red-600 dark:text-red-400",
|
|
31
31
|
title: "text-xl font-semibold text-zinc-900 dark:text-zinc-100",
|
|
32
32
|
subtitle: "text-sm text-red-600 dark:text-red-400"
|
|
33
|
+
},
|
|
34
|
+
ready: {
|
|
35
|
+
iconWrapper: "w-16 h-16 rounded-full bg-blue-100 dark:bg-blue-900/30 flex items-center justify-center",
|
|
36
|
+
icon: "w-8 h-8 text-blue-600 dark:text-blue-400",
|
|
37
|
+
title: "text-xl font-semibold text-zinc-900 dark:text-zinc-100",
|
|
38
|
+
subtitle: "text-sm text-zinc-500 dark:text-zinc-400",
|
|
39
|
+
button: "mt-6 w-full px-6 py-3 text-sm font-semibold text-white bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-400 dark:text-black rounded-xl transition-all duration-200 active:scale-[0.98] shadow-lg shadow-blue-600/20 dark:shadow-blue-500/20"
|
|
33
40
|
}
|
|
34
41
|
},
|
|
35
42
|
backButton: "mt-6 px-6 py-2.5 text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors duration-200"
|
|
@@ -22,6 +22,7 @@ export interface MagicLinkVerifyPageConfig {
|
|
|
22
22
|
onBackToLogin?: () => void;
|
|
23
23
|
backToLoginHref?: string;
|
|
24
24
|
redirectDelay?: number;
|
|
25
|
+
requireConfirmation?: boolean;
|
|
25
26
|
className?: string;
|
|
26
27
|
texts?: {
|
|
27
28
|
verifyingTitle?: string;
|
|
@@ -30,6 +31,9 @@ export interface MagicLinkVerifyPageConfig {
|
|
|
30
31
|
successSubtitle?: string;
|
|
31
32
|
errorTitle?: string;
|
|
32
33
|
backToLogin?: string;
|
|
34
|
+
confirmTitle?: string;
|
|
35
|
+
confirmSubtitle?: string;
|
|
36
|
+
confirmButton?: string;
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
39
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.48",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|