<?php
declare(strict_types=1);

/*
|--------------------------------------------------------------------------
| Security Headers
|--------------------------------------------------------------------------
*/

if (!headers_sent()) {

    // MIME sniffing band
    header('X-Content-Type-Options: nosniff');

    // Clickjacking protection
    header('X-Frame-Options: SAMEORIGIN');

    // Referrer policy
    header('Referrer-Policy: strict-origin-when-cross-origin');

    // Browser permissions
    header("Permissions-Policy: camera=(), microphone=(), geolocation=()");

    // XSS filter (legacy browsers)
    header('X-XSS-Protection: 1; mode=block');

    // Disable FLoC / Topics
    header('Permissions-Policy: browsing-topics=()');

    /*
    |--------------------------------------------------------------------------
    | Content Security Policy
    |--------------------------------------------------------------------------
    | Agar future me CDN use karoge (Google Fonts, CDNJS, etc.)
    | to isko update karna padega.
    */

    header(
        "Content-Security-Policy: "
        ."default-src 'self'; "
        ."script-src 'self' 'unsafe-inline'; "
        ."style-src 'self' 'unsafe-inline'; "
        ."img-src 'self' data:; "
        ."font-src 'self' data:; "
        ."object-src 'none'; "
        ."base-uri 'self'; "
        ."frame-ancestors 'self'; "
        ."form-action 'self';"
    );

}