@luxfi/core 4.4.1 → 4.4.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,16 +6,16 @@ import { useAuth } from '@hanzo/auth/service'
|
|
6
6
|
const AuthListener = () => {
|
7
7
|
const auth = useAuth()
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
9
|
+
const requestAuthToken = () => {
|
10
|
+
const childFrame = document.getElementById('login') as HTMLIFrameElement
|
11
|
+
childFrame?.contentWindow?.postMessage(true, process.env.NEXT_PUBLIC_LOGIN_SITE_URL ?? '')
|
12
|
+
}
|
14
13
|
|
14
|
+
useEffect(() => {
|
15
15
|
const handleMessage = (event: any) => {
|
16
16
|
if (event.origin === process.env.NEXT_PUBLIC_AUTH_ORIGIN) {
|
17
17
|
const token = event.data
|
18
|
-
|
18
|
+
auth.loginWithCustomToken(token)
|
19
19
|
}
|
20
20
|
}
|
21
21
|
|
@@ -26,7 +26,7 @@ const AuthListener = () => {
|
|
26
26
|
}
|
27
27
|
}, [])
|
28
28
|
|
29
|
-
return (
|
29
|
+
return (<iframe id='login' onLoad={requestAuthToken} src={process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/>)
|
30
30
|
}
|
31
31
|
|
32
32
|
export default AuthListener
|
@@ -1,3 +1,5 @@
|
|
1
|
+
'use client'
|
2
|
+
|
1
3
|
import Link from 'next/link'
|
2
4
|
import Autoplay from 'embla-carousel-autoplay'
|
3
5
|
|
@@ -9,6 +11,7 @@ import { Logo } from '..'
|
|
9
11
|
import LuxLogo from '../icons/lux-logo'
|
10
12
|
import { legal } from '../../site-def/footer'
|
11
13
|
import domains from './common-auth-domains'
|
14
|
+
import { useEffect } from 'react'
|
12
15
|
|
13
16
|
const LoginPanel: React.FC<{
|
14
17
|
close: () => void
|
@@ -27,13 +30,28 @@ const LoginPanel: React.FC<{
|
|
27
30
|
const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
|
28
31
|
|
29
32
|
const onLogin = (token: string) => {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
localStorage.setItem('auth-token', token)
|
34
|
+
for (const { url } of domains) {
|
35
|
+
parent?.contentWindow?.postMessage(token, url)
|
33
36
|
}
|
34
37
|
}
|
35
38
|
|
36
|
-
|
39
|
+
useEffect(() => {
|
40
|
+
const handleMessage = (event: any) => {
|
41
|
+
if (domains.includes(event.origin)) {
|
42
|
+
const token = localStorage.getItem('auth-token')
|
43
|
+
parent.contentWindow?.postMessage(token, event.origin)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
window.addEventListener('message', handleMessage)
|
48
|
+
|
49
|
+
return () => {
|
50
|
+
window.removeEventListener('message', handleMessage)
|
51
|
+
}
|
52
|
+
}, [])
|
53
|
+
|
54
|
+
return (
|
37
55
|
<div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
|
38
56
|
<div className='hidden md:flex w-full h-full bg-level-1 flex-row items-end justify-end overflow-y-auto min-h-screen'>
|
39
57
|
<div className='h-full w-full max-w-[750px] px-8 pt-0'>
|
@@ -86,12 +104,7 @@ const LoginPanel: React.FC<{
|
|
86
104
|
</div>
|
87
105
|
</div>
|
88
106
|
</div>
|
89
|
-
|
90
|
-
{domains.map(({ id, url }) => (
|
91
|
-
<iframe key={id} id={id} src={`${url}/login`} />
|
92
|
-
))}
|
93
|
-
</div>
|
94
|
-
</>)
|
107
|
+
)
|
95
108
|
}
|
96
109
|
|
97
110
|
export default LoginPanel
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@luxfi/core",
|
3
|
-
"version": "4.4.
|
3
|
+
"version": "4.4.3",
|
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,8 +39,8 @@
|
|
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.2",
|
43
|
+
"@hanzo/commerce": "6.4.2",
|
44
44
|
"@hanzo/ui": "3.6.3",
|
45
45
|
"@next/third-parties": "^14.1.0",
|
46
46
|
"embla-carousel-autoplay": "^8.0.1",
|