diff --git a/packages/client-core/src/user/services/AuthService.ts b/packages/client-core/src/user/services/AuthService.ts index eab61984e9..90c525c1fb 100755 --- a/packages/client-core/src/user/services/AuthService.ts +++ b/packages/client-core/src/user/services/AuthService.ts @@ -39,7 +39,6 @@ import { stateNamespaceKey, syncStateWithLocalStorage } from '@etherealengine/hyperflux' -import openPopup from "../../util/open-popup"; import { AvatarID, @@ -222,7 +221,7 @@ const getToken = async(): Promise => { const authState = getMutableState(AuthState) const accessToken = authState?.authUser?.accessToken?.value return Promise.resolve(accessToken?.length > 0 ? accessToken : null) - } //else window.location.href = `${clientUrl}/main-site-cookie-acknowledgment.html?redirect=${window.location}` + } else { iframe.style.display = 'block' return await new Promise(resolve => { @@ -239,11 +238,12 @@ const getToken = async(): Promise => { const hasAccessListener = async function(e) { console.log('got message from iframe for hasAccessListener', e, e?.data) window.removeEventListener('message', hasAccessListener) - if (!e.data) resolve({ hasStorageAccess: false, cookieSet: false }) + if (!e.data) resolve('') const data = JSON.parse(e.data) console.log('data', data) console.log('Waiting for token after click') const token = await waitForToken(win, clientUrl) + iframe.style.display = 'none' resolve(token) } window.addEventListener('message', hasAccessListener) diff --git a/packages/client/index.html b/packages/client/index.html index c6243e61db..18afd5aa79 100755 --- a/packages/client/index.html +++ b/packages/client/index.html @@ -47,6 +47,30 @@ }) }) } + + //Base height and width of cross-origin iframe + const w = 300 + const h = 400 + + const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX; + const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY; + + let width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; + let height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; + + const systemZoom = width / window.screen.availWidth; + const left = (width - w) / 2 / systemZoom + dualScreenLeft + const topSetting = (height - h) / 2 / systemZoom + dualScreenTop + + document.addEventListener('DOMContentLoaded', async (event) => { + console.log('Setting root iframe style') + const rootIframe = document.getElementById('root-cookie-accessor') + console.log('rootIframe', rootIframe) + rootIframe.style.width = `${w / systemZoom}px` + rootIframe.style.height = `${h / systemZoom}px` + rootIframe.style.top = `${topSetting}px` + rootIframe.style.left = `${left}px` + }) diff --git a/packages/client/public/main-site-cookie-acknowledgment.html b/packages/client/public/main-site-cookie-acknowledgment.html deleted file mode 100644 index 33d03a31a9..0000000000 --- a/packages/client/public/main-site-cookie-acknowledgment.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - Request Storage Access - - - - -

This site runs on Ethereal Engine. To automatically use your login across all Ethereal Engine-powered sites, please confirm below. If you decline, then each Ethereal Engine-powered site will log in separately, and you will receive this prompt on all Ethereal Engine-powered sites.

-
- - -
- - \ No newline at end of file diff --git a/packages/client/public/root-cookie-accessor-template.html b/packages/client/public/root-cookie-accessor-template.html index 48f8d51b37..ce04cf0198 100644 --- a/packages/client/public/root-cookie-accessor-template.html +++ b/packages/client/public/root-cookie-accessor-template.html @@ -106,9 +106,18 @@ console.log('Cookie accessor loaded') document.getElementById('confirmButton').onclick = async event => { console.log('confirmButton clicked') - document.cookie = 'visited=true; SameSite=None; Secure' + // document.cookie = 'visited=true; SameSite=None; Secure' const requestStorageAccessResponse = await document.requestStorageAccess() console.log('requestStorageAccessResponse', requestStorageAccessResponse) + if (requestStorageAccessResponse == null) { + console.log('storage access granted') + + const cookieSet = document.cookie && document.cookie + .split("; ") + .find((row) => row.startsWith(`visited=`) || row.startsWith('allowedDomains=')) + console.log('cookieset', cookieSet) + parent.postMessage(JSON.stringify({ hasStorageAccess: true, cookieSet }), origin) + } //If there's a redirect URL, then upon completion, go back to the original URL // if (isRedirect) { diff --git a/scripts/build_minikube.sh b/scripts/build_minikube.sh index 39e94d40e8..8f8ffca5f4 100755 --- a/scripts/build_minikube.sh +++ b/scripts/build_minikube.sh @@ -53,14 +53,14 @@ fi if [ -z "$VITE_APP_HOST" ] then - VITE_APP_HOST=local.etherealengine.org + VITE_APP_HOST=meep.etherealengine.uk else VITE_APP_HOST=$VITE_APP_HOST fi if [ -z "$VITE_SERVER_HOST" ] then - VITE_SERVER_HOST=api-local.etherealengine.org + VITE_SERVER_HOST=api-meep.etherealengine.uk else VITE_SERVER_HOST=$VITE_SERVER_HOST fi @@ -81,7 +81,7 @@ fi if [ -z "$VITE_INSTANCESERVER_HOST" ] then - VITE_INSTANCESERVER_HOST=instanceserver-local.etherealengine.org + VITE_INSTANCESERVER_HOST=instanceserver-meep.etherealengine.uk else VITE_INSTANCESERVER_HOST=$VITE_INSTANCESERVER_HOST fi @@ -128,7 +128,7 @@ else VITE_FEATHERS_STORE_KEY=VITE_FEATHERS_STORE_KEY fi - +echo $VITE_APP_HOST # ./generate-certs.sh