Commit aae435fe authored by tom's avatar tom

fix csp warnings and delete console

parent 4feeb9db
...@@ -16,22 +16,21 @@ const MAIN_DOMAINS = [ `*.${ appConfig.host }`, appConfig.host ]; ...@@ -16,22 +16,21 @@ const MAIN_DOMAINS = [ `*.${ appConfig.host }`, appConfig.host ];
// eslint-disable-next-line no-restricted-properties // eslint-disable-next-line no-restricted-properties
const REPORT_URI = process.env.SENTRY_CSP_REPORT_URI; const REPORT_URI = process.env.SENTRY_CSP_REPORT_URI;
function getNetworksExternalAssets() { function getNetworksExternalAssetsHosts() {
const icons = featuredNetworks const icons = featuredNetworks
.filter(({ icon }) => typeof icon === 'string') .filter(({ icon }) => typeof icon === 'string')
.map(({ icon }) => new URL(icon as string)); .map(({ icon }) => new URL(icon as string).host);
const logo = appConfig.network.logo ? new URL(appConfig.network.logo) : undefined; const logo = appConfig.network.logo ? new URL(appConfig.network.logo).host : undefined;
return logo ? icons.concat(logo) : icons; return logo ? icons.concat(logo) : icons;
} }
function getMarketplaceAppsOrigins() { function getMarketplaceAppsHosts() {
return appConfig.marketplaceAppList.map(({ url }) => url); return {
} frames: appConfig.marketplaceAppList.map(({ url }) => new URL(url).host),
logos: appConfig.marketplaceAppList.map(({ logo }) => new URL(logo).host),
function getMarketplaceAppsLogosOrigins() { };
return appConfig.marketplaceAppList.map(({ logo }) => new URL(logo));
} }
// we cannot use lodash/uniq in middleware code since it calls new Set() and it'is causing an error in Nextjs // we cannot use lodash/uniq in middleware code since it calls new Set() and it'is causing an error in Nextjs
...@@ -46,7 +45,7 @@ function unique(array: Array<string | undefined>) { ...@@ -46,7 +45,7 @@ function unique(array: Array<string | undefined>) {
} }
function makePolicyMap() { function makePolicyMap() {
const networkExternalAssets = getNetworksExternalAssets(); const marketplaceAppsHosts = getMarketplaceAppsHosts();
return { return {
'default-src': [ 'default-src': [
...@@ -130,10 +129,10 @@ function makePolicyMap() { ...@@ -130,10 +129,10 @@ function makePolicyMap() {
'avatars.githubusercontent.com', // github avatars 'avatars.githubusercontent.com', // github avatars
// network assets // network assets
...networkExternalAssets.map((url) => url.host), ...getNetworksExternalAssetsHosts(),
// marketplace apps logos // marketplace apps logos
...getMarketplaceAppsLogosOrigins().map((url) => url.host), ...marketplaceAppsHosts.logos,
// ad // ad
'servedbyadbutler.com', 'servedbyadbutler.com',
...@@ -167,7 +166,7 @@ function makePolicyMap() { ...@@ -167,7 +166,7 @@ function makePolicyMap() {
], ],
'frame-src': [ 'frame-src': [
...getMarketplaceAppsOrigins(), ...marketplaceAppsHosts.frames,
// ad // ad
'request-global.czilladx.com', 'request-global.czilladx.com',
......
...@@ -14,14 +14,6 @@ export default function useGetCsrfToken() { ...@@ -14,14 +14,6 @@ export default function useGetCsrfToken() {
const url = buildUrl('csrf'); const url = buildUrl('csrf');
const apiResponse = await fetch(url, { credentials: 'include' }); const apiResponse = await fetch(url, { credentials: 'include' });
const csrfFromHeader = apiResponse.headers.get('x-bs-account-csrf'); const csrfFromHeader = apiResponse.headers.get('x-bs-account-csrf');
// eslint-disable-next-line no-console
console.log('>>> RESPONSE HEADERS <<<');
// eslint-disable-next-line no-console
console.table([ {
'content-length': apiResponse.headers.get('content-length'),
'x-bs-account-csrf': csrfFromHeader,
} ]);
return csrfFromHeader ? { token: csrfFromHeader } : undefined; return csrfFromHeader ? { token: csrfFromHeader } : undefined;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment