@redzone/taunt-logins-ui-react 0.0.12 → 0.0.14

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.
@@ -0,0 +1,644 @@
1
+ function __insertCSS(code) {
2
+ if (!code || typeof document == 'undefined') return
3
+ let head = document.head || document.getElementsByTagName('head')[0]
4
+ let style = document.createElement('style')
5
+ style.type = 'text/css'
6
+ head.appendChild(style)
7
+ ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
+ }
9
+
10
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
+ import { useCallback, createContext, useContext, useState, useMemo, useEffect } from 'react';
12
+ import { _ as _async_to_generator, a as _extends, b as _object_without_properties_loose } from './cc-D6TRVNtd.js';
13
+ import { TauntApi, tauntMagicEmailOTPLogin, tauntMetamaskLogin, tauntMagicTelegramLogin } from '@redzone/taunt-logins';
14
+
15
+ __insertCSS(".rzd-loginui-complete{background:radial-gradient(50% 50% at 50% 50%,#132c50 0,#0b101b 100%);border-radius:37px;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:20px;padding:40px;max-width:620px;min-height:455px;min-width:500px}.rzd-loginview{box-sizing:border-box;color:#fff;font-size:36px;font-weight:700;color:#fff;text-transform:uppercase;margin:20px 0}.logo{height:6em;padding:1.5em;will-change:filter;transition:filter .3s}.logo:hover{filter:drop-shadow(0 0 2em #646cffaa)}.logo.react:hover{filter:drop-shadow(0 0 2em #61dafbaa)}.card{padding:2em}.read-the-docs{color:#888}input.rdz-input{box-sizing:border-box;position:relative;width:100%;max-width:480px;height:58px;border:2px solid #009df3;box-shadow:0 0 16.9px 1px #0e79f3;border-radius:11px}input.rdz-input::placeholder{color:#fff;opacity:1;font-family:\"Futura PT\",sans-serif;font-size:1em}.rdz-magic-email-container{display:flex;flex-direction:column;align-items:center;gap:12px;width:100%}.rdz-magic-email-error{color:red}.rdz-sign-up-text{font-family:\"Futura PT\",sans-serif;font-size:1.2em;font-weight:400}.rdz-icon-button{width:55px;height:55px;border-radius:50%;border:none;background-color:transparent;cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center;transition:transform .2s ease,filter .2s ease}.rdz-icon-button img{width:100%;height:100%;object-fit:contain}.rdz-icon-button:hover{transform:scale(1.1);filter:brightness(1.1)}.rdz-icon-button:active{transform:scale(.95)}.rdz-icon-button-disabled,.rdz-icon-button:disabled{opacity:.4;cursor:not-allowed;filter:grayscale(100%);pointer-events:none}.rdz-icon-button-disabled:hover,.rdz-icon-button:disabled:hover{transform:none;filter:grayscale(100%)}.rdz-magic-email-button{background-size:100% 100%;background-position:center;background-repeat:no-repeat;font-family:DRUNKWIDE,sans-serif;border:none;color:#fff;padding:16px 32px;cursor:pointer;min-height:135px;margin-bottom:-20px;width:100%;max-width:410px;font-size:22px;font-weight:700;text-transform:uppercase;letter-spacing:1px;background-color:transparent;transition:transform .2s ease,filter .2s ease}.rdz-magic-email-button:hover{transform:scale(1.05);filter:brightness(1.1)}.rdz-magic-email-button:active{transform:scale(.98)}.rdz-logout-button{margin-left:8px;padding:12px 24px;background-color:#3b82f6;color:#fff;border-radius:6px;border:none;cursor:pointer;font-family:\"Futura PT\",sans-serif;font-size:16px;font-weight:500;transition:transform .2s ease,filter .2s ease}.rdz-logout-button:hover{transform:scale(1.05);filter:brightness(1.1)}.rdz-logout-button:active{transform:scale(.98)}");
16
+
17
+ const coinbaseLogo = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030923/coinbase_kyknjr.png";
18
+ const CoinbaseButton = ({ openCoinbase, disabled = false })=>{
19
+ const runCoinbase = useCallback(()=>{
20
+ if (disabled) return;
21
+ if (openCoinbase) {
22
+ openCoinbase();
23
+ } else {
24
+ console.log("Coinbase login not yet implemented");
25
+ }
26
+ }, [
27
+ openCoinbase,
28
+ disabled
29
+ ]);
30
+ return /*#__PURE__*/ jsx("button", {
31
+ className: `rdz-icon-button ${disabled ? "rdz-icon-button-disabled" : ""}`,
32
+ onClick: runCoinbase,
33
+ disabled: disabled,
34
+ children: /*#__PURE__*/ jsx("img", {
35
+ src: coinbaseLogo,
36
+ alt: "Coinbase"
37
+ })
38
+ });
39
+ };
40
+
41
+ function LoadingView() {
42
+ return /*#__PURE__*/ jsxs("div", {
43
+ className: "rzd-loginview",
44
+ style: {
45
+ display: "flex",
46
+ flexDirection: "column",
47
+ alignItems: "center",
48
+ gap: 20
49
+ },
50
+ children: [
51
+ /*#__PURE__*/ jsx("h1", {
52
+ children: "Processing..."
53
+ }),
54
+ /*#__PURE__*/ jsx("div", {
55
+ style: {
56
+ width: "60px",
57
+ height: "60px",
58
+ border: "4px solid #009df3",
59
+ borderTop: "4px solid transparent",
60
+ borderRadius: "50%",
61
+ animation: "spin 1s linear infinite"
62
+ }
63
+ }),
64
+ /*#__PURE__*/ jsx("style", {
65
+ children: `
66
+ @keyframes spin {
67
+ 0% { transform: rotate(0deg); }
68
+ 100% { transform: rotate(360deg); }
69
+ }
70
+ `
71
+ }),
72
+ /*#__PURE__*/ jsx("p", {
73
+ style: {
74
+ fontFamily: "Futura PT, sans-serif",
75
+ fontSize: "1.2em",
76
+ color: "white"
77
+ },
78
+ children: "Please wait while we authenticate you..."
79
+ })
80
+ ]
81
+ });
82
+ }
83
+
84
+ const TauntContext = createContext({
85
+ tauntServiceEndpoint: "",
86
+ isLoading: false,
87
+ loggedIn: false,
88
+ metamaskLogin: ()=>{},
89
+ otpMagicLogin: ()=>{},
90
+ telegramLogin: ()=>{},
91
+ metaLogin: ()=>{},
92
+ coinbaseLogin: ()=>{},
93
+ refreshToken: (token)=>_async_to_generator(function*() {})(),
94
+ getClaimrToken: ()=>Promise.resolve(undefined),
95
+ getClaimrData: ()=>Promise.resolve(undefined),
96
+ logout: ()=>{}
97
+ });
98
+ function useTaunt() {
99
+ const ctx = useContext(TauntContext);
100
+ if (!ctx) {
101
+ throw new Error("useTaunt must be used within a TauntProvider");
102
+ }
103
+ return ctx;
104
+ }
105
+
106
+ const btnImage = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030925/btn_ioay6n.png";
107
+ const MagicEmailInput = ({ onEmail })=>{
108
+ const { otpMagicLogin } = useTaunt();
109
+ const [email, setEmail] = useState();
110
+ const [showError, setShowError] = useState(false);
111
+ const validEmail = useMemo(()=>{
112
+ const validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
113
+ return (email == null ? void 0 : email.match(validRegex)) ? email : undefined;
114
+ }, [
115
+ email
116
+ ]);
117
+ const runMagic = ()=>{
118
+ if (!validEmail) {
119
+ setShowError(true);
120
+ return;
121
+ }
122
+ setShowError(false);
123
+ if (onEmail) {
124
+ onEmail(email);
125
+ } else {
126
+ otpMagicLogin(email);
127
+ }
128
+ };
129
+ return /*#__PURE__*/ jsxs("div", {
130
+ className: "rdz-magic-email-container",
131
+ children: [
132
+ showError && /*#__PURE__*/ jsx("div", {
133
+ className: "rdz-magic-email-error",
134
+ children: "Please enter a valid email"
135
+ }),
136
+ /*#__PURE__*/ jsx("input", {
137
+ className: "rdz-input",
138
+ onChange: (e)=>setEmail(e.target.value ? e.target.value : undefined),
139
+ placeholder: "Email address",
140
+ type: "email",
141
+ value: email
142
+ }),
143
+ /*#__PURE__*/ jsx("button", {
144
+ onClick: runMagic,
145
+ type: "button",
146
+ className: "rdz-magic-email-button",
147
+ style: {
148
+ backgroundImage: `url(${btnImage})`
149
+ },
150
+ children: "LOG IN / SIGN UP"
151
+ })
152
+ ]
153
+ });
154
+ };
155
+
156
+ const metaLogo = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030923/meta_rhrjov.png";
157
+ const MetaButton = ({ openMeta, disabled = false })=>{
158
+ // const { metaLogin } = useTaunt() // Uncomment when meta login is implemented
159
+ const runMeta = useCallback(()=>{
160
+ if (disabled) return;
161
+ if (openMeta) {
162
+ openMeta();
163
+ } else {
164
+ // metaLogin() // Uncomment when meta login is implemented
165
+ console.log("Meta login not yet implemented");
166
+ }
167
+ }, [
168
+ openMeta,
169
+ disabled
170
+ ]);
171
+ return /*#__PURE__*/ jsx("button", {
172
+ className: `rdz-icon-button ${disabled ? 'rdz-icon-button-disabled' : ''}`,
173
+ onClick: runMeta,
174
+ disabled: disabled,
175
+ children: /*#__PURE__*/ jsx("img", {
176
+ src: metaLogo,
177
+ alt: "Meta"
178
+ })
179
+ });
180
+ };
181
+
182
+ const metamaskLogo = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030924/metamask_asjtmi.png";
183
+ const MetaMaskButton = ({ openMetamask, disabled = false })=>{
184
+ const { metamaskLogin } = useTaunt();
185
+ const runMetamask = useCallback(()=>{
186
+ if (disabled) return;
187
+ if (openMetamask) {
188
+ openMetamask();
189
+ } else {
190
+ metamaskLogin();
191
+ }
192
+ }, [
193
+ metamaskLogin,
194
+ openMetamask,
195
+ disabled
196
+ ]);
197
+ return /*#__PURE__*/ jsx("button", {
198
+ className: `rdz-icon-button ${disabled ? 'rdz-icon-button-disabled' : ''}`,
199
+ onClick: runMetamask,
200
+ disabled: disabled,
201
+ children: /*#__PURE__*/ jsx("img", {
202
+ src: metamaskLogo,
203
+ alt: "MetaMask"
204
+ })
205
+ });
206
+ };
207
+
208
+ const telegramLogo = "https://res.cloudinary.com/dz0wa3qbj/image/upload/v1760030924/tel_vcs64d.png";
209
+ const TelegramButton = ({ openTelegram, disabled = false })=>{
210
+ const { telegramLogin } = useTaunt();
211
+ const runTelegram = useCallback(()=>{
212
+ if (disabled) return;
213
+ if (openTelegram) {
214
+ openTelegram();
215
+ } else {
216
+ telegramLogin();
217
+ }
218
+ }, [
219
+ telegramLogin,
220
+ openTelegram,
221
+ disabled
222
+ ]);
223
+ return /*#__PURE__*/ jsx("button", {
224
+ className: `rdz-icon-button ${disabled ? 'rdz-icon-button-disabled' : ''}`,
225
+ onClick: runTelegram,
226
+ disabled: disabled,
227
+ children: /*#__PURE__*/ jsx("img", {
228
+ src: telegramLogo,
229
+ alt: "Telegram"
230
+ })
231
+ });
232
+ };
233
+
234
+ const LoginView = ({ providers = [
235
+ "email",
236
+ "metamask",
237
+ "telegram",
238
+ "meta",
239
+ "coinbase"
240
+ ], showEmail = true, showDisabled = false, dividerText = "Or Sign Up Using", providerGap = 20, showTerms = false, termsContent, privacyContent, onTermsClick, onPrivacyClick, ModalComponent, magicEmailProps = {}, coinbaseProps = {}, metamaskProps = {}, metaProps = {}, telegramProps = {} })=>{
241
+ const [modalContent, setModalContent] = useState(null);
242
+ const showEmailInput = showEmail || providers.includes("email");
243
+ const allSocialProviders = [
244
+ "coinbase",
245
+ "metamask",
246
+ "meta",
247
+ "telegram"
248
+ ];
249
+ // Determine which social providers to show
250
+ const socialProvidersToShow = showDisabled ? allSocialProviders : allSocialProviders.filter((p)=>providers.includes(p));
251
+ const hasSocialProviders = socialProvidersToShow.length > 0;
252
+ const handleTermsClick = ()=>{
253
+ console.log("Terms clicked", {
254
+ onTermsClick,
255
+ termsContent: !!termsContent
256
+ });
257
+ if (onTermsClick) {
258
+ onTermsClick();
259
+ } else if (termsContent) {
260
+ setModalContent({
261
+ title: "Terms of Service",
262
+ content: termsContent
263
+ });
264
+ }
265
+ };
266
+ const handlePrivacyClick = ()=>{
267
+ console.log("Privacy clicked", {
268
+ onPrivacyClick,
269
+ privacyContent: !!privacyContent
270
+ });
271
+ if (onPrivacyClick) {
272
+ onPrivacyClick();
273
+ } else if (privacyContent) {
274
+ setModalContent({
275
+ title: "Privacy Policy",
276
+ content: privacyContent
277
+ });
278
+ }
279
+ };
280
+ return /*#__PURE__*/ jsxs(Fragment, {
281
+ children: [
282
+ showEmailInput && /*#__PURE__*/ jsx(MagicEmailInput, _extends({}, magicEmailProps)),
283
+ showEmailInput && hasSocialProviders && /*#__PURE__*/ jsx("p", {
284
+ className: "rdz-sign-up-text",
285
+ children: dividerText
286
+ }),
287
+ hasSocialProviders && /*#__PURE__*/ jsxs("div", {
288
+ style: {
289
+ display: "flex",
290
+ flexDirection: "row",
291
+ gap: providerGap,
292
+ alignItems: "center"
293
+ },
294
+ children: [
295
+ socialProvidersToShow.includes("coinbase") && /*#__PURE__*/ jsx(CoinbaseButton, _extends({
296
+ disabled: !providers.includes("coinbase")
297
+ }, coinbaseProps)),
298
+ socialProvidersToShow.includes("metamask") && /*#__PURE__*/ jsx(MetaMaskButton, _extends({
299
+ disabled: !providers.includes("metamask")
300
+ }, metamaskProps)),
301
+ socialProvidersToShow.includes("meta") && /*#__PURE__*/ jsx(MetaButton, _extends({
302
+ disabled: !providers.includes("meta")
303
+ }, metaProps)),
304
+ socialProvidersToShow.includes("telegram") && /*#__PURE__*/ jsx(TelegramButton, _extends({
305
+ disabled: !providers.includes("telegram")
306
+ }, telegramProps))
307
+ ]
308
+ }),
309
+ console.log("Terms render check:", {
310
+ showTerms,
311
+ hasTermsContent: !!termsContent,
312
+ hasPrivacyContent: !!privacyContent,
313
+ hasTermsClick: !!onTermsClick,
314
+ hasPrivacyClick: !!onPrivacyClick
315
+ }),
316
+ showTerms && (termsContent || privacyContent || onTermsClick || onPrivacyClick) && /*#__PURE__*/ jsxs("p", {
317
+ style: {
318
+ fontFamily: "Futura PT, sans-serif",
319
+ fontSize: "1.3em"
320
+ },
321
+ children: [
322
+ "By connecting you are agreeing to our",
323
+ " ",
324
+ (termsContent || onTermsClick) && /*#__PURE__*/ jsx("a", {
325
+ href: "#",
326
+ onClick: (e)=>{
327
+ e.preventDefault();
328
+ handleTermsClick();
329
+ },
330
+ style: {
331
+ color: "#0099ff",
332
+ textDecoration: "none",
333
+ cursor: "pointer"
334
+ },
335
+ children: "Terms of Service"
336
+ }),
337
+ (termsContent || onTermsClick) && (privacyContent || onPrivacyClick) && " and ",
338
+ (privacyContent || onPrivacyClick) && /*#__PURE__*/ jsx("a", {
339
+ href: "#",
340
+ onClick: (e)=>{
341
+ e.preventDefault();
342
+ handlePrivacyClick();
343
+ },
344
+ style: {
345
+ color: "#0099ff",
346
+ textDecoration: "none",
347
+ cursor: "pointer"
348
+ },
349
+ children: "Privacy Policy"
350
+ })
351
+ ]
352
+ }),
353
+ modalContent && ModalComponent && /*#__PURE__*/ jsxs(Fragment, {
354
+ children: [
355
+ console.log("Rendering modal", {
356
+ modalContent,
357
+ ModalComponent: !!ModalComponent
358
+ }),
359
+ /*#__PURE__*/ jsx(ModalComponent, {
360
+ title: modalContent.title,
361
+ content: modalContent.content,
362
+ onClose: ()=>setModalContent(null)
363
+ })
364
+ ]
365
+ })
366
+ ]
367
+ });
368
+ };
369
+
370
+ const LoginUIComplete = (_param)=>{
371
+ var { className, extLoading = false } = _param, loginProps = _object_without_properties_loose(_param, [
372
+ "className",
373
+ "extLoading"
374
+ ]);
375
+ const { loggedIn, isLoading } = useTaunt();
376
+ return /*#__PURE__*/ jsx("div", {
377
+ className: `rzd-loginview rzd-loginui-complete ${className || ""}`,
378
+ children: extLoading || isLoading ? /*#__PURE__*/ jsx(LoadingView, {}) : loggedIn ? /*#__PURE__*/ jsx(LoggedInView, {}) : /*#__PURE__*/ jsxs(Fragment, {
379
+ children: [
380
+ /*#__PURE__*/ jsx("h1", {
381
+ className: "header-login",
382
+ children: "login"
383
+ }),
384
+ /*#__PURE__*/ jsx(LoginView, _extends({}, loginProps))
385
+ ]
386
+ })
387
+ });
388
+ };
389
+ function LoggedInView() {
390
+ return /*#__PURE__*/ jsxs(Fragment, {
391
+ children: [
392
+ /*#__PURE__*/ jsx("h1", {
393
+ children: "Successfully Logged In"
394
+ }),
395
+ /*#__PURE__*/ jsx("p", {
396
+ style: {
397
+ fontFamily: "Futura PT, sans-serif",
398
+ fontSize: "1.2em"
399
+ },
400
+ children: "You are now logged in!"
401
+ }),
402
+ /*#__PURE__*/ jsx(LogoutButton, {})
403
+ ]
404
+ });
405
+ }
406
+ function LogoutButton() {
407
+ const { logout } = useTaunt();
408
+ return /*#__PURE__*/ jsx("button", {
409
+ onClick: logout,
410
+ className: "rdz-logout-button",
411
+ type: "button",
412
+ children: "Logout"
413
+ });
414
+ }
415
+
416
+ function ModalView({ title, content, onClose }) {
417
+ // Close modal on Escape key
418
+ useEffect(()=>{
419
+ const handleEscape = (e)=>{
420
+ if (e.key === "Escape") onClose();
421
+ };
422
+ document.addEventListener("keydown", handleEscape);
423
+ return ()=>document.removeEventListener("keydown", handleEscape);
424
+ }, [
425
+ onClose
426
+ ]);
427
+ // Parse content to identify headers and format them
428
+ const formatContent = (text)=>{
429
+ const lines = text.split("\n");
430
+ return lines.map((line, index)=>{
431
+ const trimmedLine = line.trim();
432
+ // First line is the main title (h1)
433
+ if (index === 0 && trimmedLine) {
434
+ return /*#__PURE__*/ jsx("h1", {
435
+ style: {
436
+ marginTop: 0,
437
+ marginBottom: "20px",
438
+ fontSize: "28px"
439
+ },
440
+ children: trimmedLine
441
+ }, index);
442
+ }
443
+ // Section headers (lines that are short and followed by content)
444
+ // Common patterns: "Table of contents", "User content", etc.
445
+ if (trimmedLine && trimmedLine.length < 100 && !trimmedLine.includes(".") && index < lines.length - 1 && lines[index + 1].trim()) {
446
+ // Check if next line starts with lowercase or is a paragraph
447
+ const nextLine = lines[index + 1].trim();
448
+ if (nextLine && (nextLine[0] === nextLine[0].toUpperCase() || nextLine.startsWith("We "))) {
449
+ return /*#__PURE__*/ jsx("h3", {
450
+ style: {
451
+ marginTop: "24px",
452
+ marginBottom: "12px",
453
+ fontSize: "18px",
454
+ fontWeight: "600"
455
+ },
456
+ children: trimmedLine
457
+ }, index);
458
+ }
459
+ }
460
+ // Regular paragraphs
461
+ if (trimmedLine) {
462
+ return /*#__PURE__*/ jsx("p", {
463
+ style: {
464
+ marginBottom: "12px"
465
+ },
466
+ children: trimmedLine
467
+ }, index);
468
+ }
469
+ // Empty lines
470
+ return /*#__PURE__*/ jsx("br", {}, index);
471
+ });
472
+ };
473
+ return /*#__PURE__*/ jsx("div", {
474
+ style: {
475
+ position: "fixed",
476
+ top: 0,
477
+ left: 0,
478
+ right: 0,
479
+ bottom: 0,
480
+ backgroundColor: "rgba(0, 0, 0, 0.8)",
481
+ display: "flex",
482
+ alignItems: "center",
483
+ justifyContent: "center",
484
+ zIndex: 1000,
485
+ padding: "20px"
486
+ },
487
+ onClick: onClose,
488
+ children: /*#__PURE__*/ jsxs("div", {
489
+ style: {
490
+ backgroundColor: "#1a1a1a",
491
+ borderRadius: "12px",
492
+ border: "2px solid #009df3",
493
+ maxWidth: "800px",
494
+ maxHeight: "80vh",
495
+ width: "100%",
496
+ display: "flex",
497
+ flexDirection: "column",
498
+ overflow: "hidden"
499
+ },
500
+ onClick: (e)=>e.stopPropagation(),
501
+ children: [
502
+ /*#__PURE__*/ jsxs("div", {
503
+ style: {
504
+ padding: "20px 24px",
505
+ borderBottom: "1px solid #009df3",
506
+ display: "flex",
507
+ justifyContent: "space-between",
508
+ alignItems: "center"
509
+ },
510
+ children: [
511
+ /*#__PURE__*/ jsx("h2", {
512
+ style: {
513
+ fontFamily: "Futura PT, sans-serif",
514
+ margin: 0,
515
+ color: "white",
516
+ fontSize: "24px"
517
+ },
518
+ children: title
519
+ }),
520
+ /*#__PURE__*/ jsx("button", {
521
+ onClick: onClose,
522
+ style: {
523
+ background: "transparent",
524
+ border: "none",
525
+ color: "white",
526
+ fontSize: "32px",
527
+ cursor: "pointer",
528
+ padding: "0 10px",
529
+ lineHeight: 1
530
+ },
531
+ children: "×"
532
+ })
533
+ ]
534
+ }),
535
+ /*#__PURE__*/ jsx("div", {
536
+ style: {
537
+ padding: "24px",
538
+ overflow: "auto",
539
+ flex: 1,
540
+ fontFamily: "Futura PT, sans-serif",
541
+ fontSize: "15px",
542
+ lineHeight: "1.6",
543
+ color: "white",
544
+ textAlign: "left"
545
+ },
546
+ children: formatContent(content)
547
+ })
548
+ ]
549
+ })
550
+ });
551
+ }
552
+
553
+ const TauntProvider = ({ children, tauntServiceEndpoint, magicKey })=>{
554
+ const [deets, setDeets] = useState();
555
+ const taunt = new TauntApi(tauntServiceEndpoint);
556
+ const [isLoading, setIsLoading] = useState(false);
557
+ const loggedIn = !!deets;
558
+ const otpMagicLogin = useCallback((email)=>{
559
+ if (!magicKey) throw new Error("magicKey is required for OTP login");
560
+ setIsLoading(true);
561
+ tauntMagicEmailOTPLogin(tauntServiceEndpoint, magicKey, email, taunt).then(setDeets).finally(()=>setIsLoading(false));
562
+ }, [
563
+ tauntServiceEndpoint,
564
+ magicKey
565
+ ]);
566
+ const metamaskLogin = useCallback(()=>{
567
+ setIsLoading(true);
568
+ tauntMetamaskLogin(tauntServiceEndpoint, undefined, taunt).then(setDeets).finally(()=>setIsLoading(false));
569
+ }, [
570
+ tauntServiceEndpoint
571
+ ]);
572
+ const telegramLogin = useCallback(()=>{
573
+ if (!magicKey) throw new Error("magicKey is required for Telegram login");
574
+ setIsLoading(true);
575
+ tauntMagicTelegramLogin(tauntServiceEndpoint, magicKey, taunt).then(setDeets).finally(()=>setIsLoading(false));
576
+ }, [
577
+ tauntServiceEndpoint,
578
+ magicKey
579
+ ]);
580
+ const metaLogin = useCallback(()=>{
581
+ setIsLoading(true);
582
+ console.log("Meta login not yet implemented");
583
+ // Placeholder for Meta login
584
+ setTimeout(()=>setIsLoading(false), 1000);
585
+ }, []);
586
+ const coinbaseLogin = useCallback(()=>{
587
+ setIsLoading(true);
588
+ console.log("Coinbase login not yet implemented");
589
+ // Placeholder for Coinbase login
590
+ setTimeout(()=>setIsLoading(false), 1000);
591
+ }, []);
592
+ const getClaimrToken = useCallback(()=>{
593
+ if (!loggedIn) return undefined;
594
+ return taunt.getClaimrToken();
595
+ }, [
596
+ loggedIn
597
+ ]);
598
+ const logout = useCallback(()=>{
599
+ setDeets(undefined);
600
+ }, []);
601
+ const refreshToken = useCallback((token)=>_async_to_generator(function*() {
602
+ if (!token) return;
603
+ setIsLoading(true);
604
+ try {
605
+ const newDeets = yield taunt.refresh(token);
606
+ setDeets(newDeets);
607
+ } catch (error) {
608
+ console.error("Failed to refresh token:", error);
609
+ } finally{
610
+ setIsLoading(false);
611
+ }
612
+ })(), []);
613
+ const getClaimrData = useCallback(()=>{
614
+ if (!loggedIn) return undefined;
615
+ return taunt.getClaimrData();
616
+ }, [
617
+ loggedIn
618
+ ]);
619
+ if (!tauntServiceEndpoint) {
620
+ return /*#__PURE__*/ jsx("div", {
621
+ children: "tauntServiceEndpoint is required"
622
+ });
623
+ }
624
+ return /*#__PURE__*/ jsx(TauntContext.Provider, {
625
+ value: {
626
+ tauntServiceEndpoint,
627
+ loggedIn,
628
+ isLoading,
629
+ deets,
630
+ getClaimrData,
631
+ getClaimrToken,
632
+ otpMagicLogin,
633
+ metamaskLogin,
634
+ telegramLogin,
635
+ metaLogin,
636
+ coinbaseLogin,
637
+ refreshToken,
638
+ logout
639
+ },
640
+ children: children
641
+ });
642
+ };
643
+
644
+ export { CoinbaseButton, LoadingView, LoginUIComplete, LoginView, MagicEmailInput, MetaButton, MetaMaskButton, ModalView, TauntContext, TauntProvider, TelegramButton, useTaunt };