
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@httpland/coep-middleware
Advanced tools
HTTP cross-origin embedder policy(COEP) middleware.
Compliant with HTML Living Standard, 7.1.4 Cross-origin embedder policies.
For a definition of Universal HTTP middleware, see the http-middleware project.
Middleware adds the Cross-Origin-Embedder-Policy header to the response.
import {
coep,
type Handler,
} from "https://deno.land/x/coep_middleware@$VERSION/mod.ts";
import { assert } from "https://deno.land/std/testing/asserts.ts";
declare const request: Request;
declare const handler: Handler;
const middleware = coep();
const response = await middleware(request, handler);
assert(response.headers.has("cross-origin-embedder-policy"));
yield:
Cross-Origin-Embedder-Policy: require-corp
The middleware factory accepts the following fields:
| Name | Type | Default | Description |
|---|---|---|---|
| policy | "require-corp" | "unsafe-none" | credentialless | "require-corp" | Embedder policy value. |
| reportTo | string | - | Reporting endpoint name. |
| reportOnly | boolean | false | Whether header is report-only or not. |
If specified, change the embedder policy value.
import { coep } from "https://deno.land/x/coep_middleware@$VERSION/middleware.ts";
const middleware = coep({ policy: "credentialless" });
yield:
Cross-Origin-Embedder-Policy: credentialless
If specified, adds a report-to param to the output.
import { coep } from "https://deno.land/x/coep_middleware@$VERSION/middleware.ts";
const middleware = coep({ reportTo: "default" });
yield:
Cross-Origin-Embedder-Policy: require-corp;report-to=default
Depending on the value, the header will be:
| Value | Field name |
|---|---|
true | Cross-Origin-Embedder-Policy-Report-Only |
false | Cross-Origin-Embedder-Policy |
import { coep } from "https://deno.land/x/coep_middleware@$VERSION/middleware.ts";
const middleware = coep({ reportOnly: true });
yield:
Cross-Origin-Embedder-Policy-Report-Only: require-corp
If serialize of embedder policy fails, it may throw TypeError.
Serialize fails in the following cases:
reportTo field is an invalid
<sf-token>
syntaximport { coep } from "https://deno.land/x/coep_middleware@$VERSION/middleware.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";
assertThrows(() => coep({ reportTo: "<invalid>" }));
Middleware will execute if all of the following conditions are met:
Cross-Origin-Embedder-Policy headerCross-Origin-Embedder-Policy-Report-Only headerMiddleware may make changes to the following elements of the HTTP message.
All APIs can be found in the deno doc.
Copyright © 2023-present httpland.
Released under the MIT license
FAQs
HTTP cross-origin embedder policy(COEP) middleware
The npm package @httpland/coep-middleware receives a total of 5 weekly downloads. As such, @httpland/coep-middleware popularity was classified as not popular.
We found that @httpland/coep-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.