fix and update

This commit is contained in:
lendry
2026-07-01 12:05:34 +03:00
parent f8f25c8289
commit dce16af5a5
2 changed files with 29 additions and 3 deletions

View File

@@ -33,9 +33,34 @@ export function applyFedcmPreflightHeaders(res: Response, origin?: string) {
res.setHeader('Access-Control-Max-Age', '86400');
}
/**
* FedCM-запросы должны иметь Sec-Fetch-Dest: webidentity (или empty, если прокси
* не пробрасывает заголовок). Блокируем только явно «не-FedCM» dest (document,
* script, image…) — иначе well-known/config отдают 400 и One Tap ломается.
*/
const BLOCKED_FEDCM_FETCH_DEST = new Set([
'document',
'embed',
'frame',
'iframe',
'object',
'script',
'style',
'image',
'font',
'audio',
'video',
'track',
'worker',
'serviceworker',
'sharedworker',
'manifest',
'xslt'
]);
export function assertFedcmWebIdentityRequest(req: Request) {
const dest = String(req.headers['sec-fetch-dest'] ?? '').toLowerCase();
if (dest && dest !== 'webidentity') {
if (dest && BLOCKED_FEDCM_FETCH_DEST.has(dest)) {
throw new BadRequestException('Недопустимый Sec-Fetch-Dest для FedCM');
}
}