message: chore: update security headers
diff: // Adds additional headers to the response, including security headers.
  // Suited for websites.
  //
  -// Usage: Create an AWS Lambda@Edge function and attach it to "Viewer Response" event of a Cloudfront distribution
  +// See also:
  +// - https://securityheaders.com/
  +//
  +// Usage: Create an AWS Lambda@Edge function and attach it to "Viewer Response"
  +// event of a Cloudfront distribution
  const FEATURE_POLICY = {
  - 'accelerometer': `'none'`,
  - 'autoplay': `'none'`,
  - 'camera': `'none'`,
  - 'document-domain': `'none'`,
  - 'encrypted-media': `'none'`,
  - 'fullscreen': `'none'`,
  - 'geolocation': `'none'`,
  - 'gyroscope': `'none'`,
  - 'magnetometer': `'none'`,
  - 'microphone': `'none'`,
  - 'midi': `'none'`,
  - 'payment': `'none'`,
  - 'picture-in-picture': `'none'`,
  - 'sync-xhr': `'none'`,
  - 'usb': `'none'`,
  - 'xr-spatial-tracking': `'none'`,
  + accelerometer: `'none'`,
  + camera: `'none'`,
  + geolocation: `'none'`,
  + gyroscope: `'none'`,
  + magnetometer: `'none'`,
  + microphone: `'none'`,
  + payment: `'none'`,
  + usb: `'none'`,
  }
  function generateFeaturePolicyHeader(featurePolicyObject) {
  @@ -28,6 +24,23 @@ function generateFeaturePolicyHeader(featurePolicyObject) {
  .join('; ')
  }
  +const PERMISSIONS_POLICY = {
  + 'accelerometer': '()',
  + 'camera': '()',
  + 'geolocation': '()',
  + 'gyroscope': '()',
  + 'magnetometer': '()',
  + 'microphone': '()',
  + 'payment': '()',
  + 'usb': '()',
  + 'interest-cohort': '()',
  +}
  +
  +function generatePermissionsPolicyHeader(permissionsPolicyObject) {
  + return Object.entries(permissionsPolicyObject)
  + .map(([policy, value]) => `${policy}=${value}`)
  + .join(', ')
  +}
  const NEW_HEADERS = {
  'Content-Security-Policy':
  "default-src 'self'; script-src 'self' 'unsafe-eval' plausible.io; style-src 'self' 'unsafe-inline'; img-src 'self' data: *.githubusercontent.com; connect-src *",
  @@ -39,6 +52,7 @@ const NEW_HEADERS = {
  'X-Frame-Options': 'SAMEORIGIN',
  'X-XSS-Protection': '1; mode=block',
  'Feature-Policy': generateFeaturePolicyHeader(FEATURE_POLICY),
  + 'Permissions-Policy': generatePermissionsPolicyHeader(PERMISSIONS_POLICY),
  }
  function addHeaders(headersObject) {
  @@ -63,7 +77,7 @@ function filterHeaders(headers) {
  }, {})
  }
  -function modifyHeaders({ request, response }) {
  +function modifyHeaders({ response }) {
  let newHeaders = addHeaders(NEW_HEADERS)
  newHeaders = {
  @@ -73,18 +87,6 @@ function modifyHeaders({ request, response }) {
  newHeaders = filterHeaders(newHeaders)
  - const url = request.uri || request.url
  - if (url.startsWith('/_next')) {
  - const cacheHeaders = addHeaders({
  - 'Cache-Control': 'public,max-age=31536000,immutable',
  - })
  -
  - newHeaders = {
  - ...newHeaders,
  - ...cacheHeaders,
  - }
  - }
  -
  return newHeaders
  }
  