@luxfi/core 4.3.18 → 4.4.3

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,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
+ const requestAuthToken = () => {
10
+ const childFrame = document.getElementById('login') as HTMLIFrameElement
11
+ childFrame?.contentWindow?.postMessage(true, process.env.NEXT_PUBLIC_LOGIN_SITE_URL ?? '')
12
+ }
13
+
14
+ useEffect(() => {
15
+ const handleMessage = (event: any) => {
16
+ if (event.origin === process.env.NEXT_PUBLIC_AUTH_ORIGIN) {
17
+ const token = event.data
18
+ auth.loginWithCustomToken(token)
19
+ }
20
+ }
21
+
22
+ window.addEventListener('message', handleMessage)
23
+
24
+ return () => {
25
+ window.removeEventListener('message', handleMessage)
26
+ }
27
+ }, [])
28
+
29
+ return (<iframe id='login' onLoad={requestAuthToken} src={process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/>)
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
+ }
@@ -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
 
@@ -8,6 +10,8 @@ import { LoginPanel as Login } from '@hanzo/auth/components'
8
10
  import { Logo } from '..'
9
11
  import LuxLogo from '../icons/lux-logo'
10
12
  import { legal } from '../../site-def/footer'
13
+ import domains from './common-auth-domains'
14
+ import { useEffect } from 'react'
11
15
 
12
16
  const LoginPanel: React.FC<{
13
17
  close: () => void
@@ -25,6 +29,28 @@ const LoginPanel: React.FC<{
25
29
  const termsOfServiceUrl = legal.find(({title}) => title === 'Terms and Conditions')?.href || ''
26
30
  const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
27
31
 
32
+ const onLogin = (token: string) => {
33
+ localStorage.setItem('auth-token', token)
34
+ for (const { url } of domains) {
35
+ parent?.contentWindow?.postMessage(token, url)
36
+ }
37
+ }
38
+
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
+
28
54
  return (
29
55
  <div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
30
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'>
@@ -72,6 +98,7 @@ const LoginPanel: React.FC<{
72
98
  className='w-full max-w-sm'
73
99
  termsOfServiceUrl={termsOfServiceUrl}
74
100
  privacyPolicyUrl={privacyPolicyUrl}
101
+ onLoginChanged={onLogin}
75
102
  />
76
103
  </div>
77
104
  </div>
@@ -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.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.3.6",
43
- "@hanzo/commerce": "6.3.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",
@@ -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
+ }