@redzone/taunt-logins-ui-react 0.0.18 → 0.0.19
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/cjs/index.cjs +16 -8
- package/dist/cjs/index.d.cts +4 -5
- package/dist/es/index.d.ts +4 -5
- package/dist/es/index.js +16 -8
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -85,6 +85,7 @@ const TauntContext = react.createContext({
|
|
|
85
85
|
tauntServiceEndpoint: "",
|
|
86
86
|
isLoading: false,
|
|
87
87
|
loggedIn: false,
|
|
88
|
+
setLoginDetails: ()=>{},
|
|
88
89
|
getMe: ()=>Promise.resolve(undefined),
|
|
89
90
|
metamaskLogin: ()=>{},
|
|
90
91
|
otpMagicLogin: ()=>{},
|
|
@@ -552,30 +553,30 @@ function ModalView({ title, content, onClose }) {
|
|
|
552
553
|
}
|
|
553
554
|
|
|
554
555
|
const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
555
|
-
const [
|
|
556
|
+
const [loginDetails, setLoginDetails] = react.useState();
|
|
556
557
|
const taunt = react.useMemo(()=>new tauntLogins.TauntApi(tauntServiceEndpoint), [
|
|
557
558
|
tauntServiceEndpoint
|
|
558
559
|
]);
|
|
559
560
|
const [isLoading, setIsLoading] = react.useState(false);
|
|
560
|
-
const loggedIn = !!
|
|
561
|
+
const loggedIn = !!loginDetails;
|
|
561
562
|
const otpMagicLogin = react.useCallback((email)=>{
|
|
562
563
|
if (!magicKey) throw new Error("magicKey is required for OTP login");
|
|
563
564
|
setIsLoading(true);
|
|
564
|
-
tauntLogins.tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, taunt).then(
|
|
565
|
+
tauntLogins.tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, taunt).then(setLoginDetails).finally(()=>setIsLoading(false));
|
|
565
566
|
}, [
|
|
566
567
|
tauntServiceEndpoint,
|
|
567
568
|
magicKey
|
|
568
569
|
]);
|
|
569
570
|
const metamaskLogin = react.useCallback(()=>{
|
|
570
571
|
setIsLoading(true);
|
|
571
|
-
tauntLogins.tauntMetamaskLogin(tauntServiceEndpoint, undefined, taunt).then(
|
|
572
|
+
tauntLogins.tauntMetamaskLogin(tauntServiceEndpoint, undefined, taunt).then(setLoginDetails).finally(()=>setIsLoading(false));
|
|
572
573
|
}, [
|
|
573
574
|
tauntServiceEndpoint
|
|
574
575
|
]);
|
|
575
576
|
const telegramLogin = react.useCallback(()=>{
|
|
576
577
|
if (!magicKey) throw new Error("magicKey is required for Telegram login");
|
|
577
578
|
setIsLoading(true);
|
|
578
|
-
tauntLogins.tauntMagicTelegramLogin(tauntServiceEndpoint, magicKey, taunt).then(
|
|
579
|
+
tauntLogins.tauntMagicTelegramLogin(tauntServiceEndpoint, magicKey, taunt).then(setLoginDetails).finally(()=>setIsLoading(false));
|
|
579
580
|
}, [
|
|
580
581
|
tauntServiceEndpoint,
|
|
581
582
|
magicKey
|
|
@@ -605,14 +606,14 @@ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
|
605
606
|
loggedIn
|
|
606
607
|
]);
|
|
607
608
|
const logout = react.useCallback(()=>{
|
|
608
|
-
|
|
609
|
+
setLoginDetails(undefined);
|
|
609
610
|
}, []);
|
|
610
611
|
const refreshToken = react.useCallback((token)=>cc._async_to_generator(function*() {
|
|
611
612
|
if (!token) return;
|
|
612
613
|
setIsLoading(true);
|
|
613
614
|
try {
|
|
614
615
|
const newDeets = yield taunt.refresh(token);
|
|
615
|
-
|
|
616
|
+
setLoginDetails(newDeets);
|
|
616
617
|
} catch (error) {
|
|
617
618
|
console.error("Failed to refresh token:", error);
|
|
618
619
|
} finally{
|
|
@@ -625,6 +626,11 @@ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
|
625
626
|
})(), [
|
|
626
627
|
loggedIn
|
|
627
628
|
]);
|
|
629
|
+
const safeSetLoginDetails = react.useCallback((props)=>cc._async_to_generator(function*() {
|
|
630
|
+
taunt.setLoginDetails(props).then(setLoginDetails);
|
|
631
|
+
})(), [
|
|
632
|
+
taunt
|
|
633
|
+
]);
|
|
628
634
|
if (!tauntServiceEndpoint) {
|
|
629
635
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
630
636
|
children: "tauntServiceEndpoint is required"
|
|
@@ -635,7 +641,9 @@ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
|
635
641
|
tauntServiceEndpoint,
|
|
636
642
|
loggedIn,
|
|
637
643
|
isLoading,
|
|
638
|
-
deets,
|
|
644
|
+
deets: loginDetails,
|
|
645
|
+
loginDetails,
|
|
646
|
+
setLoginDetails: safeSetLoginDetails,
|
|
639
647
|
getMe,
|
|
640
648
|
getClaimrData,
|
|
641
649
|
getClaimrToken,
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { TauntUser, ClaimrCampaignData } from '@redzone/taunt-logins';
|
|
3
|
+
import { TauntAccessDetails, TauntUser, ClaimrCampaignData } from '@redzone/taunt-logins';
|
|
4
4
|
|
|
5
5
|
interface CoinbaseButtonProps {
|
|
6
6
|
openCoinbase?: () => void;
|
|
@@ -86,11 +86,10 @@ declare function ModalView({ title, content, onClose }: ModalProps): react_jsx_r
|
|
|
86
86
|
type ContextProps = {
|
|
87
87
|
tauntServiceEndpoint: string;
|
|
88
88
|
loggedIn: boolean;
|
|
89
|
-
deets?:
|
|
90
|
-
|
|
91
|
-
refreshToken: string;
|
|
92
|
-
};
|
|
89
|
+
deets?: TauntAccessDetails;
|
|
90
|
+
loginDetails?: TauntAccessDetails;
|
|
93
91
|
isLoading: boolean;
|
|
92
|
+
setLoginDetails: (props: TauntAccessDetails) => void;
|
|
94
93
|
getMe: () => Promise<TauntUser | undefined>;
|
|
95
94
|
metamaskLogin: () => void;
|
|
96
95
|
otpMagicLogin: (email: string) => void;
|
package/dist/es/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { TauntUser, ClaimrCampaignData } from '@redzone/taunt-logins';
|
|
3
|
+
import { TauntAccessDetails, TauntUser, ClaimrCampaignData } from '@redzone/taunt-logins';
|
|
4
4
|
|
|
5
5
|
interface CoinbaseButtonProps {
|
|
6
6
|
openCoinbase?: () => void;
|
|
@@ -86,11 +86,10 @@ declare function ModalView({ title, content, onClose }: ModalProps): react_jsx_r
|
|
|
86
86
|
type ContextProps = {
|
|
87
87
|
tauntServiceEndpoint: string;
|
|
88
88
|
loggedIn: boolean;
|
|
89
|
-
deets?:
|
|
90
|
-
|
|
91
|
-
refreshToken: string;
|
|
92
|
-
};
|
|
89
|
+
deets?: TauntAccessDetails;
|
|
90
|
+
loginDetails?: TauntAccessDetails;
|
|
93
91
|
isLoading: boolean;
|
|
92
|
+
setLoginDetails: (props: TauntAccessDetails) => void;
|
|
94
93
|
getMe: () => Promise<TauntUser | undefined>;
|
|
95
94
|
metamaskLogin: () => void;
|
|
96
95
|
otpMagicLogin: (email: string) => void;
|
package/dist/es/index.js
CHANGED
|
@@ -85,6 +85,7 @@ const TauntContext = createContext({
|
|
|
85
85
|
tauntServiceEndpoint: "",
|
|
86
86
|
isLoading: false,
|
|
87
87
|
loggedIn: false,
|
|
88
|
+
setLoginDetails: ()=>{},
|
|
88
89
|
getMe: ()=>Promise.resolve(undefined),
|
|
89
90
|
metamaskLogin: ()=>{},
|
|
90
91
|
otpMagicLogin: ()=>{},
|
|
@@ -552,30 +553,30 @@ function ModalView({ title, content, onClose }) {
|
|
|
552
553
|
}
|
|
553
554
|
|
|
554
555
|
const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
555
|
-
const [
|
|
556
|
+
const [loginDetails, setLoginDetails] = useState();
|
|
556
557
|
const taunt = useMemo(()=>new TauntApi(tauntServiceEndpoint), [
|
|
557
558
|
tauntServiceEndpoint
|
|
558
559
|
]);
|
|
559
560
|
const [isLoading, setIsLoading] = useState(false);
|
|
560
|
-
const loggedIn = !!
|
|
561
|
+
const loggedIn = !!loginDetails;
|
|
561
562
|
const otpMagicLogin = useCallback((email)=>{
|
|
562
563
|
if (!magicKey) throw new Error("magicKey is required for OTP login");
|
|
563
564
|
setIsLoading(true);
|
|
564
|
-
tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, taunt).then(
|
|
565
|
+
tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, taunt).then(setLoginDetails).finally(()=>setIsLoading(false));
|
|
565
566
|
}, [
|
|
566
567
|
tauntServiceEndpoint,
|
|
567
568
|
magicKey
|
|
568
569
|
]);
|
|
569
570
|
const metamaskLogin = useCallback(()=>{
|
|
570
571
|
setIsLoading(true);
|
|
571
|
-
tauntMetamaskLogin(tauntServiceEndpoint, undefined, taunt).then(
|
|
572
|
+
tauntMetamaskLogin(tauntServiceEndpoint, undefined, taunt).then(setLoginDetails).finally(()=>setIsLoading(false));
|
|
572
573
|
}, [
|
|
573
574
|
tauntServiceEndpoint
|
|
574
575
|
]);
|
|
575
576
|
const telegramLogin = useCallback(()=>{
|
|
576
577
|
if (!magicKey) throw new Error("magicKey is required for Telegram login");
|
|
577
578
|
setIsLoading(true);
|
|
578
|
-
tauntMagicTelegramLogin(tauntServiceEndpoint, magicKey, taunt).then(
|
|
579
|
+
tauntMagicTelegramLogin(tauntServiceEndpoint, magicKey, taunt).then(setLoginDetails).finally(()=>setIsLoading(false));
|
|
579
580
|
}, [
|
|
580
581
|
tauntServiceEndpoint,
|
|
581
582
|
magicKey
|
|
@@ -605,14 +606,14 @@ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
|
605
606
|
loggedIn
|
|
606
607
|
]);
|
|
607
608
|
const logout = useCallback(()=>{
|
|
608
|
-
|
|
609
|
+
setLoginDetails(undefined);
|
|
609
610
|
}, []);
|
|
610
611
|
const refreshToken = useCallback((token)=>_async_to_generator(function*() {
|
|
611
612
|
if (!token) return;
|
|
612
613
|
setIsLoading(true);
|
|
613
614
|
try {
|
|
614
615
|
const newDeets = yield taunt.refresh(token);
|
|
615
|
-
|
|
616
|
+
setLoginDetails(newDeets);
|
|
616
617
|
} catch (error) {
|
|
617
618
|
console.error("Failed to refresh token:", error);
|
|
618
619
|
} finally{
|
|
@@ -625,6 +626,11 @@ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
|
625
626
|
})(), [
|
|
626
627
|
loggedIn
|
|
627
628
|
]);
|
|
629
|
+
const safeSetLoginDetails = useCallback((props)=>_async_to_generator(function*() {
|
|
630
|
+
taunt.setLoginDetails(props).then(setLoginDetails);
|
|
631
|
+
})(), [
|
|
632
|
+
taunt
|
|
633
|
+
]);
|
|
628
634
|
if (!tauntServiceEndpoint) {
|
|
629
635
|
return /*#__PURE__*/ jsx("div", {
|
|
630
636
|
children: "tauntServiceEndpoint is required"
|
|
@@ -635,7 +641,9 @@ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
|
|
|
635
641
|
tauntServiceEndpoint,
|
|
636
642
|
loggedIn,
|
|
637
643
|
isLoading,
|
|
638
|
-
deets,
|
|
644
|
+
deets: loginDetails,
|
|
645
|
+
loginDetails,
|
|
646
|
+
setLoginDetails: safeSetLoginDetails,
|
|
639
647
|
getMe,
|
|
640
648
|
getClaimrData,
|
|
641
649
|
getClaimrToken,
|