@luxfi/core 4.4.3 → 4.4.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
'use client'
|
2
2
|
|
3
|
-
import { useEffect } from
|
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
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
if (window) {
|
23
|
+
window.addEventListener('message', handleMessage)
|
24
|
+
|
25
|
+
return () => {
|
26
|
+
window.removeEventListener('message', handleMessage)
|
27
|
+
}
|
26
28
|
}
|
27
29
|
}, [])
|
28
30
|
|
29
|
-
return (
|
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
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.
|
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
|
-
|
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 =
|
47
|
+
const token = getCookie('auth-token')
|
43
48
|
parent.contentWindow?.postMessage(token, event.origin)
|
44
49
|
}
|
45
50
|
}
|
46
51
|
|
47
|
-
window
|
48
|
-
|
49
|
-
|
50
|
-
|
52
|
+
if (window) {
|
53
|
+
window.addEventListener('message', handleMessage)
|
54
|
+
|
55
|
+
return () => {
|
56
|
+
window.removeEventListener('message', handleMessage)
|
57
|
+
}
|
51
58
|
}
|
52
59
|
}, [])
|
53
60
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@luxfi/core",
|
3
|
-
"version": "4.4.
|
3
|
+
"version": "4.4.5",
|
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.
|
43
|
-
"@hanzo/commerce": "6.4.
|
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"
|