@luxfi/core 4.4.4 → 4.4.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.
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
 
3
- import { useEffect } from "react"
3
+ import { useEffect } from 'react'
4
4
  import { useAuth } from '@hanzo/auth/service'
5
5
 
6
6
  const AuthListener = () => {
@@ -19,14 +19,23 @@ const AuthListener = () => {
19
19
  }
20
20
  }
21
21
 
22
- window.addEventListener('message', handleMessage)
22
+ if (typeof window !== 'undefined') {
23
+ window.addEventListener('message', handleMessage)
23
24
 
24
- return () => {
25
- window.removeEventListener('message', handleMessage)
25
+ return () => {
26
+ window.removeEventListener('message', handleMessage)
27
+ }
26
28
  }
27
29
  }, [])
28
30
 
29
- return (<iframe id='login' onLoad={requestAuthToken} src={process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/>)
31
+ return (
32
+ <iframe
33
+ id='login'
34
+ onLoad={requestAuthToken}
35
+ src={`${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/login`}
36
+ className='hidden'
37
+ />
38
+ )
30
39
  }
31
40
 
32
- export default AuthListener
41
+ export default AuthListener
@@ -1,10 +1,13 @@
1
1
  const domains = [
2
2
  { id: 'lux.market', url: 'https://lux.market' },
3
+ { id: 'lux.shop', url: 'https://lux.shop' },
3
4
  { id: 'lux.credit', url: 'https://lux.credit' },
4
5
  { id: 'lux.network', url: 'https://lux.network' },
5
- { id: 'lux.shop', url: 'https://lux.shop' },
6
+ { id: 'wallet.lux.network', url: 'https://wallet.lux.network' },
7
+ { id: 'safe.lux.network', url: 'https://safe.lux.network' },
6
8
  { id: 'lux.finance', url: 'https://lux.finance' },
7
9
  { id: 'lux.exchange', url: 'https://lux.exchange' },
10
+ { id: 'lux.quest', url: 'https://lux.quest' },
8
11
  ]
9
12
 
10
13
  export {
@@ -1,7 +1,10 @@
1
1
  'use client'
2
2
 
3
+ import { useEffect } from 'react'
4
+ import { useRouter } from 'next/navigation'
3
5
  import Link from 'next/link'
4
6
  import Autoplay from 'embla-carousel-autoplay'
7
+ import { getCookie , setCookie } from 'cookies-next'
5
8
 
6
9
  import { cn } from '@hanzo/ui/util'
7
10
  import { Button, Carousel, CarouselContent, CarouselItem } from '@hanzo/ui/primitives'
@@ -11,7 +14,6 @@ import { Logo } from '..'
11
14
  import LuxLogo from '../icons/lux-logo'
12
15
  import { legal } from '../../site-def/footer'
13
16
  import domains from './common-auth-domains'
14
- import { useEffect } from 'react'
15
17
 
16
18
  const LoginPanel: React.FC<{
17
19
  close: () => void
@@ -26,28 +28,33 @@ const LoginPanel: React.FC<{
26
28
  className='',
27
29
  reviews
28
30
  }) => {
31
+ const router = useRouter()
32
+
29
33
  const termsOfServiceUrl = legal.find(({title}) => title === 'Terms and Conditions')?.href || ''
30
34
  const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
31
35
 
32
36
  const onLogin = (token: string) => {
33
- localStorage.setItem('auth-token', token)
37
+ setCookie('auth-token', token, { sameSite: 'none', secure: true })
34
38
  for (const { url } of domains) {
35
39
  parent?.contentWindow?.postMessage(token, url)
36
40
  }
41
+ redirectUrl && router.replace(redirectUrl)
37
42
  }
38
43
 
39
44
  useEffect(() => {
40
45
  const handleMessage = (event: any) => {
41
46
  if (domains.includes(event.origin)) {
42
- const token = localStorage.getItem('auth-token')
47
+ const token = getCookie('auth-token')
43
48
  parent.contentWindow?.postMessage(token, event.origin)
44
49
  }
45
50
  }
46
51
 
47
- window.addEventListener('message', handleMessage)
52
+ if (typeof window !== 'undefined') {
53
+ window.addEventListener('message', handleMessage)
48
54
 
49
- return () => {
50
- window.removeEventListener('message', handleMessage)
55
+ return () => {
56
+ window.removeEventListener('message', handleMessage)
57
+ }
51
58
  }
52
59
  }, [])
53
60
 
@@ -62,7 +69,7 @@ const LoginPanel: React.FC<{
62
69
  className='w-fit !min-w-0 p-2'
63
70
  >
64
71
  <Logo size='md' spanClassName='!cursor-pointer' layout='text-only'/>
65
- </Button>
72
+ </Button>
66
73
  <Carousel
67
74
  options={{ align: 'center', loop: true }}
68
75
  className='w-full'
@@ -92,8 +99,8 @@ const LoginPanel: React.FC<{
92
99
  >
93
100
  <LuxLogo className='w-5 h-5'/>
94
101
  </Button>
95
- <Login
96
- getStartedUrl={getStartedUrl}
102
+ <Login
103
+ getStartedUrl={getStartedUrl}
97
104
  redirectUrl={redirectUrl}
98
105
  className='w-full max-w-sm'
99
106
  termsOfServiceUrl={termsOfServiceUrl}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxfi/core",
3
- "version": "4.4.4",
3
+ "version": "4.4.6",
4
4
  "description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -39,10 +39,11 @@
39
39
  "./conf": "./conf/index.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@hanzo/auth": "2.4.2",
43
- "@hanzo/commerce": "6.4.2",
42
+ "@hanzo/auth": "2.4.3",
43
+ "@hanzo/commerce": "6.4.3",
44
44
  "@hanzo/ui": "3.6.3",
45
45
  "@next/third-parties": "^14.1.0",
46
+ "cookies-next": "^4.1.1",
46
47
  "embla-carousel-autoplay": "^8.0.1",
47
48
  "react-device-detect": "^2.2.3",
48
49
  "react-social-icons": "^6.4.0"