Skip to content

Commit

Permalink
chore(permissions): add interest-cohort (#213)
Browse files Browse the repository at this point in the history
* chore(permissions): add interest-cohort

* Update index.test.ts

* Update index.test.ts

* Create friendly-drinks-cheat.md
  • Loading branch information
mcansh authored Jan 2, 2025
1 parent 02c4017 commit 4105e69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/friendly-drinks-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mcansh/http-helmet": patch
---

add support for interest-cohort to permissions policy
3 changes: 2 additions & 1 deletion packages/http-helmet/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ it("generates a config", () => {
autoplay: ["https://example.com"],
camera: ["*"],
fullscreen: ["self", "https://example.com", "https://example.org"],
interestCohort: [],
},
"X-XSS-Protection": "1; report=https://google.com",
"Cross-Origin-Embedder-Policy": "require-corp",
Expand All @@ -42,7 +43,7 @@ it("generates a config", () => {
"upgrade-insecure-requests; default-src 'self'; script-src 'sha512-sdhgsgh'; img-src 'none'",
);
expect(headers.get("Permissions-Policy")).toBe(
`battery=(), accelerometer=(self), autoplay=("https://example.com"), camera=*, fullscreen=(self "https://example.com" "https://example.org")`,
`battery=(), accelerometer=(self), autoplay=("https://example.com"), camera=*, fullscreen=(self "https://example.com" "https://example.org"), interest-cohort=()`
);
expect(headers.get("X-XSS-Protection")).toBe("1; report=https://google.com");
expect(headers.get("Cross-Origin-Embedder-Policy")).toBe("require-corp");
Expand Down
1 change: 1 addition & 0 deletions packages/http-helmet/src/rules/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type KnownPermissions = LiteralUnion<
| "gamepad"
| "geolocation"
| "gyroscope"
| "interestCohort"
| "layoutAnimations"
| "legacyImageFormats"
| "magnetometer"
Expand Down

0 comments on commit 4105e69

Please sign in to comment.