Socket
Socket
Sign inDemoInstall

@httpland/corp-middleware

Package Overview
Dependencies
3
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @httpland/corp-middleware

HTTP cross-origin resource policy(CORP) middleware


Version published
Weekly downloads
19
increased by5.56%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

1.0.0-beta.1 (2023-04-02)

Features

  • add middleware factory for Cross-Origin-Resource-Policy header field (8ce86dd)

Readme

Source

corp-middleware

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

HTTP cross-origin resource policy(CORP) middleware.

Compliant with Fetch, 3.6. Cross-Origin-Resource-Policy header.

Middleware

For a definition of Universal HTTP middleware, see the http-middleware project.

Usage

Middleware adds the Cross-Origin-Resource-Policy header to the response.

import {
  corp,
  type Handler,
} from "https://deno.land/x/corp_middleware@$VERSION/mod.ts";
import { assert } from "https://deno.land/std/testing/asserts.ts";

declare const request: Request;
declare const handler: Handler;

const middleware = corp();
const response = await middleware(request, handler);

assert(response.headers.has("cross-origin-resource-policy"));

yield:

Cross-Origin-Resource-Policy: same-origin

The default field value is same-origin.

Policy

To change the corp policy, do the following:

import {
  corp,
} from "https://deno.land/x/corp_middleware@$VERSION/middleware.ts";

const middleware = corp("cross-origin");

yield:

Cross-Origin-Resource-Policy: cross-origin

Conditions

Middleware will execute if all of the following conditions are met:

  • Response does not include Cross-Origin-Resource-Policy header

Effects

Middleware may make changes to the following elements of the HTTP message.

  • HTTP Headers
    • Cross-Origin-Resource-Policy

API

All APIs can be found in the deno doc.

License

Copyright © 2023-present httpland.

Released under the MIT license

Keywords

FAQs

Last updated on 02 Apr 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc