mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* debug wallet client error * Support raw text/html for NFT animation on the token instance page Resolves #2609 * fix writing to a contract with dynamic provider * change default interval for hot contracts * wait for load event of NFT embed frame * update screenshots * add network validation mode to dynamic provider * add rootstock mainnet preset * update preset for rootsrock mainnet * [skip ci] disable essential dapps for rootstock mainnet * pass required flag to FormFieldSelect controller * bump dynamic version * fix rabby wallet tx write
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { NextRequest } from 'next/server';
|
|
|
|
import generateCspPolicy from './generateCspPolicy';
|
|
import generateNftHtmlEmbedCspPolicy from './generateNftHtmlEmbedCspPolicy';
|
|
|
|
const NFT_HTML_EMBED_PATH = '/nft-html-embed.html';
|
|
|
|
let cspPolicies: { 'private': string; 'default': string } | undefined = undefined;
|
|
let nftHtmlEmbedCsp: string | undefined = undefined;
|
|
|
|
async function initializeCspPolicies() {
|
|
if (!cspPolicies) {
|
|
// Generate and cache both policies upfront
|
|
cspPolicies = {
|
|
'private': generateCspPolicy(true),
|
|
'default': generateCspPolicy(false),
|
|
};
|
|
}
|
|
}
|
|
|
|
export async function get(req?: NextRequest): Promise<string> {
|
|
await initializeCspPolicies();
|
|
|
|
// Get appProfile from request (header, query param, or cookie)
|
|
const appProfile = req ? (
|
|
req.headers.get('x-app-profile') ||
|
|
req.nextUrl.searchParams.get('app-profile') ||
|
|
req.cookies.get('app_profile')?.value
|
|
) : undefined;
|
|
|
|
const isPrivateMode = appProfile === 'private';
|
|
|
|
if (req?.nextUrl.pathname === NFT_HTML_EMBED_PATH && !isPrivateMode) {
|
|
if (!nftHtmlEmbedCsp) {
|
|
nftHtmlEmbedCsp = generateNftHtmlEmbedCspPolicy();
|
|
}
|
|
|
|
return nftHtmlEmbedCsp;
|
|
}
|
|
|
|
return isPrivateMode ? cspPolicies?.private || '' : cspPolicies?.default || '';
|
|
}
|