From d5dc222ca0c5b7ecd3eb3ea3ec41e8dc242f7bf2 Mon Sep 17 00:00:00 2001 From: ChaituVR Date: Mon, 30 Sep 2024 16:27:41 +0530 Subject: [PATCH] feat: Domains list to allow iframe on all subdomains --- src/helpers/constants.ts | 3 +++ src/main.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/helpers/constants.ts b/src/helpers/constants.ts index 1153ae05eec2..de5d21fa909d 100644 --- a/src/helpers/constants.ts +++ b/src/helpers/constants.ts @@ -23,6 +23,9 @@ export const KNOWN_HOSTS = [ 'safe.mainnet.frax.com' ]; +// All subdomains of these domains are allowed +export const KNOWN_DOMAINS = ['blockscout.com']; + export const SPACE_CATEGORIES = [ 'protocol', 'social', diff --git a/src/main.ts b/src/main.ts index 3724392f28fe..7e5ad404ae1b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,7 @@ import VueTippy from 'vue-tippy'; import VueViewer from 'v-viewer'; import { apolloClient } from '@/helpers/apollo'; // import { initSentry } from '@/sentry'; -import { KNOWN_HOSTS } from '@/helpers/constants'; +import { KNOWN_DOMAINS, KNOWN_HOSTS } from '@/helpers/constants'; import i18n from '@/helpers/i18n'; import router from '@/router'; import '@/assets/css/main.scss'; @@ -24,7 +24,11 @@ const parentUrl = ] : document.location.href; const parentHost = new URL(parentUrl).host; -if (window !== window.parent && !KNOWN_HOSTS.includes(parentHost)) { +if ( + window !== window.parent && + !KNOWN_HOSTS.includes(parentHost) && + !KNOWN_DOMAINS.includes(parentHost.split('.').slice(-2).join('.')) +) { document.documentElement.style.display = 'none'; throw new Error(`Unknown host: ${parentHost}`); }