@luxfi/core 4.3.18 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,32 @@
1
+ 'use client'
2
+
3
+ import { useEffect } from "react"
4
+ import { useAuth } from '@hanzo/auth/service'
5
+
6
+ const AuthListener = () => {
7
+ const auth = useAuth()
8
+
9
+ useEffect(() => {
10
+ if (!!localStorage.getItem('auth-token')) {
11
+ console.log("Detected auth-token cookie... Logging in...")
12
+ auth.loginWithCustomToken(localStorage.getItem('auth-token') as string)
13
+ }
14
+
15
+ const handleMessage = (event: any) => {
16
+ if (event.origin === process.env.NEXT_PUBLIC_AUTH_ORIGIN) {
17
+ const token = event.data
18
+ localStorage.setItem('auth-token', token)
19
+ }
20
+ }
21
+
22
+ window.addEventListener('message', handleMessage)
23
+
24
+ return () => {
25
+ window.removeEventListener('message', handleMessage)
26
+ }
27
+ }, [])
28
+
29
+ return (<></>)
30
+ }
31
+
32
+ export default AuthListener
@@ -0,0 +1,12 @@
1
+ const domains = [
2
+ { id: 'lux.market', url: 'https://lux.market' },
3
+ { id: 'lux.credit', url: 'https://lux.credit' },
4
+ { id: 'lux.network', url: 'https://lux.network' },
5
+ { id: 'lux.shop', url: 'https://lux.shop' },
6
+ { id: 'lux.finance', url: 'https://lux.finance' },
7
+ { id: 'lux.exchange', url: 'https://lux.exchange' },
8
+ ]
9
+
10
+ export {
11
+ domains as default
12
+ }
@@ -8,6 +8,7 @@ import { LoginPanel as Login } from '@hanzo/auth/components'
8
8
  import { Logo } from '..'
9
9
  import LuxLogo from '../icons/lux-logo'
10
10
  import { legal } from '../../site-def/footer'
11
+ import domains from './common-auth-domains'
11
12
 
12
13
  const LoginPanel: React.FC<{
13
14
  close: () => void
@@ -25,7 +26,14 @@ const LoginPanel: React.FC<{
25
26
  const termsOfServiceUrl = legal.find(({title}) => title === 'Terms and Conditions')?.href || ''
26
27
  const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
27
28
 
28
- return (
29
+ const onLogin = (token: string) => {
30
+ for (const { id, url } of domains) {
31
+ const childFrame = document.getElementById(id) as HTMLIFrameElement
32
+ childFrame?.contentWindow?.postMessage(token, url)
33
+ }
34
+ }
35
+
36
+ return (<>
29
37
  <div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
30
38
  <div className='hidden md:flex w-full h-full bg-level-1 flex-row items-end justify-end overflow-y-auto min-h-screen'>
31
39
  <div className='h-full w-full max-w-[750px] px-8 pt-0'>
@@ -72,12 +80,18 @@ const LoginPanel: React.FC<{
72
80
  className='w-full max-w-sm'
73
81
  termsOfServiceUrl={termsOfServiceUrl}
74
82
  privacyPolicyUrl={privacyPolicyUrl}
83
+ onLoginChanged={onLogin}
75
84
  />
76
85
  </div>
77
86
  </div>
78
87
  </div>
79
88
  </div>
80
- )
89
+ <div className="hidden">
90
+ {domains.map(({ id, url }) => (
91
+ <iframe key={id} id={id} src={`${url}/login`} />
92
+ ))}
93
+ </div>
94
+ </>)
81
95
  }
82
96
 
83
97
  export default LoginPanel
@@ -47,7 +47,7 @@ const BagButton: React.FC<{
47
47
  <div className={
48
48
  'z-above-content flex flex-col justify-center items-center ' +
49
49
  'absolute left-0 right-0 top-0 bottom-0 ' +
50
- 'leading-none font-sans font-bold text-foreground text-xs '
50
+ 'leading-none font-sans font-bold text-primary-fg text-xs '
51
51
  }>
52
52
  <div className='h-[3px] w-full' />
53
53
  <div>{c.cartQuantity}</div>
@@ -55,9 +55,9 @@ const MobileHeader: React.FC<{
55
55
 
56
56
  const menuOpen = () => (menuState !== 'closed')
57
57
 
58
- const onLoginChanged = (loggedIn: boolean) => {
58
+ const onLoginChanged = (token: string) => {
59
59
  // by def, menu was in state 'login'
60
- if (loggedIn) { setMenuState('nav') }
60
+ if (!!token) { setMenuState('nav') }
61
61
  }
62
62
 
63
63
  const setMenuOpen = (open: boolean) => {
@@ -2,8 +2,8 @@ import React from 'react'
2
2
  import { type LucideProps } from 'lucide-react'
3
3
 
4
4
  const BagIcon: React.FC<LucideProps> = (props: LucideProps) => (
5
- <svg fill="none" viewBox="0 0 15 18" {...props}>
6
- <path d="m13.6501 5.19282h-2.3255v-.82146c0-2.01258-1.74959-3.634971-3.87568-3.634971s-3.87572 1.622401-3.87572 3.634971v.82146h-2.32543c-.31008 0-.553678.22588-.553678.51341v10.26827c0 .7393.642278 1.3349 1.439548 1.3349h10.63056c.7973 0 1.4395-.5956 1.4395-1.3349v-10.26827c0-.28753-.2436-.51341-.5536-.51341zm-8.96955-.84198c0-1.43756 1.24021-2.60814 2.76837-2.60814 1.52815 0 2.76838 1.17055 2.76838 2.60814v.82146h-5.53675zm8.08365 11.93176h-10.63056c-.1772 0-.3322-.1438-.3322-.3081v-9.75484h1.77176v2.83405c0 .28753.2436.51341.55367.51341.31008 0 .55368-.22588.55368-.51341v-2.83405h5.53675v2.83405c0 .28753.2436.51341.5537.51341.31 0 .5536-.22588.5536-.51341v-2.83405h1.7718v9.75484c0 .1643-.155.3081-.3322.3081z" fill="currentColor"/>
5
+ <svg fill="none" viewBox="0 0 1019 1281" {...props}>
6
+ <path d="m977.243 365.553h-175.407v-90.629c0-151.923-131.968-274.924-292.334-274.924-160.367 0-292.337 123.002-292.337 274.924v90.629h-175.4023c-23.3886 0-41.7627 17.051-41.7627 38.756v775.121c0 55.8 48.4456 100.76 108.582 100.76h801.84c60.138 0 108.578-44.96 108.578-100.76v-775.121c0-21.705-18.37-38.756-41.757-38.756zm-676.553-90.629c0-108.517 93.546-196.9408 208.812-196.9408 115.265 0 208.813 88.4218 208.813 196.9408v89.08h-417.625z" fill="currentColor"/>
7
7
  </svg>
8
8
  )
9
9
 
@@ -15,6 +15,7 @@ export {
15
15
 
16
16
  export { default as CheckoutPanel } from './commerce/checkout-panel'
17
17
  export { default as LoginPanel } from './auth/login-panel'
18
+ export { default as AuthListener } from './auth/auth-listener'
18
19
 
19
20
 
20
21
  /* PLEASE KEEP
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxfi/core",
3
- "version": "4.3.18",
3
+ "version": "4.4.1",
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.3.6",
43
- "@hanzo/commerce": "6.3.4",
42
+ "@hanzo/auth": "2.4.1",
43
+ "@hanzo/commerce": "6.4.1",
44
44
  "@hanzo/ui": "3.6.3",
45
45
  "@next/third-parties": "^14.1.0",
46
46
  "embla-carousel-autoplay": "^8.0.1",
@@ -17,3 +17,15 @@
17
17
  .font-heading, h1, h2, h3 {
18
18
  @apply uppercase;
19
19
  }
20
+
21
+ /* Specific style fixes for react-square-web-payments-sdk -
22
+ * reduce gap between card input and pay button
23
+ */
24
+ #rswps-card-container {
25
+ min-height: unset !important;
26
+ }
27
+
28
+ .sq-card-wrapper .sq-card-message {
29
+ margin-top: 0 !important;
30
+ margin-bottom: 0 !important;
31
+ }