New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

http-headers-js

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-headers-js - npm Package Compare versions

Comparing version
1.0.6
to
1.0.7
+180
-170
index.js

@@ -0,1 +1,19 @@

let RespCodeIs = {
Info: function (code) {
return code > 99 && code < 200;
},
Success: function (code) {
return code > 199 && code < 300;
},
Redirect: function (code) {
return code > 299 && code < 400;
},
ClientErr: function (code) {
return code > 399 && code < 500;
},
ServerErr: function (code) {
return code > 499 && code < 600;
}
};
let ResponseCodes = {

@@ -83,178 +101,169 @@

let Methods = {
"GET": "GET",
"HEAD": "HEAD",
"POST": "POST",
"PUT": "PUT",
"OPTIONS": "OPTIONS",
"DELETE": "DELETE",
"CONNECT": "CONNECT",
"TRACE": "TRACE",
"PATCH": "PATCH",
"COPY": "COPY",
"LINK": "LINK",
"UNLINK": "UNLINK",
"PURGE": "PURGE",
"LOCK": "LOCK",
"UNLOCK": "UNLOCK",
"PROPFIND": "PROPFIND",
"VIEW": "VIEW"
"CONNECT": "CONNECT",
"COPY": "COPY",
"DELETE": "DELETE",
"GET": "GET",
"HEAD": "HEAD",
"LINK": "LINK",
"LOCK": "LOCK",
"OPTIONS": "OPTIONS",
"PATCH": "PATCH",
"POST": "POST",
"PROPFIND": "PROPFIND",
"PURGE": "PURGE",
"PUT": "PUT",
"TRACE": "TRACE",
"UNLINK": "UNLINK",
"UNLOCK": "UNLOCK",
"VIEW": "VIEW"
};
let Headers = {
/*STANDRD*/
"A_IM": "A-IM",
"ACCEPT": "Accept",
"ACCEPT_CH": "Accept-CH",
"ACCEPT_CH_LIFETIME": "Accept-CH-Lifetime",
"ACCEPT_CHARSET": "Accept-Charset",
"ACCEPT_ENCODING": "Accept-Encoding",
"ACCEPT_LANGUAGE": "Accept-Language",
"ACCEPT_DATETIME": "Accept-Datetime",
"ACCESS_CONTROL_REQUEST_METHOD": "Access-Control-Request-Method",
"ACCESS_CONTROL_REQUEST_HEADERS": "Access-Control-Request-Headers",
"ALTERNATES": "Alternates",
"AUTHORIZATION": "Authorization",
"CACHE_CONTROL": "Cache-Control",
"CONNECTION": "Connection",
"CONTENT_LENGTH": "Content-Length",
"CONTENT_MD5": "Content-MD5",
"CONTENT_TYPE": "Content-Type",
"CONTENT_VERSION": "Content-Version",
"COOKIE": "Cookie",
"DATE": "Date",
"DERIVED_FROM": "Derived-From",
"DOWNLINK": "Downlink",
"EARLY_DATA": "Early-Data",
"EXPECT": "Expect",
"FORWARDED": "Forwarded",
"FROM": "From",
"HOST": "Host",
"IF_MATCH": "If-Match",
"IF_MODIFIED_SINCE": "If-Modified-Since",
"IF_NONE_MATCH": "If-None-Match",
"IF_RANGE": "If-Range",
"IF_UNMODIFIED_SINCE": "If-Unmodified-Since",
"MAX_FORWARDS": "Max-Forwards",
"MIME_VERSION": "MIME-Version",
"ORIGIN": "Origin",
"PRAGMA": "Pragma",
"PROXY_AUTHORIZATION": "Proxy-Authorization",
"RANGE": "Range",
"REFERER": "Referer",
"REFERRER_POLICY": "Referrer-Policy",
"TE": "TE",
"SAVE_DATA": "Save-Data",
"USER_AGENT": "User-Agent",
"UPGRADE": "Upgrade",
"VIA": "Via",
"WARNING": "Warning",
"KEEP_ALIVE": "Keep-Alive",
/*COMMON*/
"UPGRADE_INSECURE_REQUESTS": "Upgrade-Insecure-Requests",
"X_REQUESTED_WITH": "X-Requested-With",
"X_ROBOTS_TAG": "X-Robots-Tag",
"DNT": "DNT",
"X_FORWARDED_FOR": "X-Forwarded-For",
"X_FORWARDED_HOST": "X-Forwarded-Host",
"X_FORWARDED_PROTO": "X-Forwarded-Proto",
"FRONT_END_HTTPS": "Front-End-Https",
"X_HTTP_METHOD_OVERRIDE": "X-Http-Method-Override",
"X_ATT_DEVICEID": "X-ATT-DeviceId",
"X_WAP_PROFILE": "X-Wap-Profile",
"PROXY_CONNECTION": "Proxy-Connection",
"X_UIDH": "X-UIDH",
"X_CSRF_TOKEN": "X-Csrf-Token",
"X_REQUEST_ID": "X-Request-ID",
"X_CORRELATION_ID": "X-Correlation-ID",
//RESPONSE
"ACCESS_CONTROL_ALLOW_ORIGIN": "Access-Control-Allow-Origin",
"ACCESS_CONTROL_ALLOW_CREDENTIALS": "Access-Control-Allow-Credentials",
"ACCESS_CONTROL_EXPOSE_HEADERS": "Access-Control-Expose-Headers",
"ACCESS_CONTROL_MAX_AGE": "Access-Control-Max-Age",
"ACCESS_CONTROL_ALLOW_METHODS": "Access-Control-Allow-Methods",
"ACCESS_CONTROL_ALLOW_HEADERS": "Access-Control-Allow-Headers",
"ACCEPT_PATCH": "Accept-Patch",
"ACCEPT_RANGES": "Accept-Ranges",
"AGE": "Age",
"ALLOW": "Allow",
"ALT_SVC": "Alt-Svc",
"CONNECTION": "Connection",
"CONTENT_DISPOSITION": "Content-Disposition",
"CONTENT_DPR": "Content-DPR",
"CONTENT_ENCODING": "Content-Encoding",
"CONTENT_LANGUAGE": "Content-Language",
"CONTENT_LOCATION": "Content-Location",
"CONTENT_RANGE": "Content-Range",
"DELTA_BASE": "Delta-Base",
"DPR": "DPR",
"ETAG": "ETag",
"EXPIRES": "Expires",
"IM": "IM",
"LAST_EVENT_ID": "Last-Event-ID",
"LAST_MODIFIED": "Last-Modified",
"LINK": "Link",
"LOCATION": "Location",
"P3P": "P3P",
"PRAGMA": "Pragma",
"PROXY_AUTHENTICATE": "Proxy-Authenticate",
"PUBLIC": "Public",
"PUBLIC_KEY_PINS": "Public-Key-Pins",
"PUBLIC_KEY_PINS_REPORT_ONLY": "Public-Key-Pins-Report-Only",
"RETRY_AFTER": "Retry-After",
"SERVER_TIMING": "Server-Timing",
"SOURCEMAP": "SourceMap",
"SERVER": "Server",
"SET_COOKIE": "Set-Cookie",
"STRICT_TRANSPORT_SECURITY": "Strict-Transport-Security",
"TRAILER": "Trailer",
"TRANSFER_ENCODING": "Transfer-Encoding",
"TITLE": "Title",
"TK": "Tk",
"VARY": "Vary",
"VIA": "Via",
"WARNING": "Warning",
"WWW_AUTHENTICATE": "WWW-Authenticate",
"X_FRAME_OPTIONS": "X-Frame-Options",
"X_PERMITTED_CROSS_DOMAIN_POLICIES": "X-Permitted-Cross-Domain-Policies",
"CONTENT_SECURITY_POLICY": "Content-Security-Policy",
"CONTENT_SECURITY_POLICY_REPORT_ONLY": "Content-Security-Policy-Report-Only",
"EXPECT_CT": "Expect-CT",
"X_CONTENT_SECURITY_POLICY": "X-Content-Security-Policy",
"X_WEBKIT_CSP": "X-WebKit-CSP",
"REFRESH": "Refresh",
"STATUS": "Status",
"TIMING_ALLOW_ORIGIN": "Timing-Allow-Origin",
"X_CONTENT_DURATION": "X-Content-Duration",
"X_CONTENT_TYPE_OPTIONS": "X-Content-Type-Options",
"X_DOWNLOAD_OPTIONS": "X-Download-Options",
"X_POWERED_BY": "X-Powered-By",
"X_REQUEST_ID": "X-Request-ID",
"X_CORRELATION_ID": "X-Correlation-ID",
"X_UA_COMPATIBLE": "X-UA-Compatible",
"X_XSS_PROTECTION": "X-XSS-Protection",
"WIDTH": "Width",
"VIEWPORT_WIDTH": "Viewport-Width",
"PING_FROM": "Ping-From",
"PING_TO": "Ping-To",
"SEC_WEBSOCKET_KEY": "Sec-WebSocket-Key",
"SEC_WEBSOCKET_EXTENSIONS": "Sec-WebSocket-Extensions",
"SEC_WEBSOCKET_ACCEPT": "Sec-WebSocket-Accept",
"SEC_WEBSOCKET_PROTOCOL": "Sec-WebSocket-Protocol",
"SEC_WEBSOCKET_VERSION": "Sec-WebSocket-Version",
"LARGE_ALLOCATION": "Large-Allocation",
"X_DNS_PREFETCH_CONTROL": "X-DNS-Prefetch-Control"
"A_IM": "A-IM",
"ACCEPT": "Accept",
"ACCEPT_CH": "Accept-CH",
"ACCEPT_CH_LIFETIME": "Accept-CH-Lifetime",
"ACCEPT_CHARSET": "Accept-Charset",
"ACCEPT_DATETIME": "Accept-Datetime",
"ACCEPT_ENCODING": "Accept-Encoding",
"ACCEPT_LANGUAGE": "Accept-Language",
"ACCEPT_PATCH": "Accept-Patch",
"ACCEPT_RANGES": "Accept-Ranges",
"ACCESS_CONTROL_ALLOW_CREDENTIALS": "Access-Control-Allow-Credentials",
"ACCESS_CONTROL_ALLOW_HEADERS": "Access-Control-Allow-Headers",
"ACCESS_CONTROL_ALLOW_METHODS": "Access-Control-Allow-Methods",
"ACCESS_CONTROL_ALLOW_ORIGIN": "Access-Control-Allow-Origin",
"ACCESS_CONTROL_EXPOSE_HEADERS": "Access-Control-Expose-Headers",
"ACCESS_CONTROL_MAX_AGE": "Access-Control-Max-Age",
"ACCESS_CONTROL_REQUEST_HEADERS": "Access-Control-Request-Headers",
"ACCESS_CONTROL_REQUEST_METHOD": "Access-Control-Request-Method",
"AGE": "Age",
"ALLOW": "Allow",
"ALT_SVC": "Alt-Svc",
"ALTERNATES": "Alternates",
"AUTHORIZATION": "Authorization",
"CACHE_CONTROL": "Cache-Control",
"CONNECTION": "Connection",
"CONTENT_DISPOSITION": "Content-Disposition",
"CONTENT_DPR": "Content-DPR",
"CONTENT_ENCODING": "Content-Encoding",
"CONTENT_LANGUAGE": "Content-Language",
"CONTENT_LENGTH": "Content-Length",
"CONTENT_LOCATION": "Content-Location",
"CONTENT_MD5": "Content-MD5",
"CONTENT_RANGE": "Content-Range",
"CONTENT_SECURITY_POLICY": "Content-Security-Policy",
"CONTENT_SECURITY_POLICY_REPORT_ONLY": "Content-Security-Policy-Report-Only",
"CONTENT_TYPE": "Content-Type",
"CONTENT_VERSION": "Content-Version",
"COOKIE": "Cookie",
"DATE": "Date",
"DELTA_BASE": "Delta-Base",
"DERIVED_FROM": "Derived-From",
"DNT": "DNT",
"DOWNLINK": "Downlink",
"DPR": "DPR",
"EARLY_DATA": "Early-Data",
"ETAG": "ETag",
"EXPECT": "Expect",
"EXPECT_CT": "Expect-CT",
"EXPIRES": "Expires",
"FORWARDED": "Forwarded",
"FROM": "From",
"FRONT_END_HTTPS": "Front-End-Https",
"HOST": "Host",
"IF_MATCH": "If-Match",
"IF_MODIFIED_SINCE": "If-Modified-Since",
"IF_NONE_MATCH": "If-None-Match",
"IF_RANGE": "If-Range",
"IF_UNMODIFIED_SINCE": "If-Unmodified-Since",
"IM": "IM",
"KEEP_ALIVE": "Keep-Alive",
"LARGE_ALLOCATION": "Large-Allocation",
"LAST_EVENT_ID": "Last-Event-ID",
"LAST_MODIFIED": "Last-Modified",
"LINK": "Link",
"LOCATION": "Location",
"MAX_FORWARDS": "Max-Forwards",
"MIME_VERSION": "MIME-Version",
"ORIGIN": "Origin",
"P3P": "P3P",
"PING_FROM": "Ping-From",
"PING_TO": "Ping-To",
"PRAGMA": "Pragma",
"PROXY_AUTHENTICATE": "Proxy-Authenticate",
"PROXY_AUTHORIZATION": "Proxy-Authorization",
"PROXY_CONNECTION": "Proxy-Connection",
"PUBLIC": "Public",
"PUBLIC_KEY_PINS": "Public-Key-Pins",
"PUBLIC_KEY_PINS_REPORT_ONLY": "Public-Key-Pins-Report-Only",
"RANGE": "Range",
"REFERER": "Referer",
"REFERRER_POLICY": "Referrer-Policy",
"REFRESH": "Refresh",
"RETRY_AFTER": "Retry-After",
"SAVE_DATA": "Save-Data",
"SEC_WEBSOCKET_ACCEPT": "Sec-WebSocket-Accept",
"SEC_WEBSOCKET_EXTENSIONS": "Sec-WebSocket-Extensions",
"SEC_WEBSOCKET_KEY": "Sec-WebSocket-Key",
"SEC_WEBSOCKET_PROTOCOL": "Sec-WebSocket-Protocol",
"SEC_WEBSOCKET_VERSION": "Sec-WebSocket-Version",
"SERVER": "Server",
"SERVER_TIMING": "Server-Timing",
"SET_COOKIE": "Set-Cookie",
"SOURCEMAP": "SourceMap",
"STATUS": "Status",
"STRICT_TRANSPORT_SECURITY": "Strict-Transport-Security",
"TE": "TE",
"TIMING_ALLOW_ORIGIN": "Timing-Allow-Origin",
"TITLE": "Title",
"TK": "Tk",
"TRAILER": "Trailer",
"TRANSFER_ENCODING": "Transfer-Encoding",
"UPGRADE": "Upgrade",
"UPGRADE_INSECURE_REQUESTS": "Upgrade-Insecure-Requests",
"USER_AGENT": "User-Agent",
"VARY": "Vary",
"VIA": "Via",
"VIEWPORT_WIDTH": "Viewport-Width",
"WARNING": "Warning",
"WIDTH": "Width",
"WWW_AUTHENTICATE": "WWW-Authenticate",
"X_ATT_DEVICEID": "X-ATT-DeviceId",
"X_CONTENT_DURATION": "X-Content-Duration",
"X_CONTENT_SECURITY_POLICY": "X-Content-Security-Policy",
"X_CONTENT_TYPE_OPTIONS": "X-Content-Type-Options",
"X_CORRELATION_ID": "X-Correlation-ID",
"X_CSRF_TOKEN": "X-Csrf-Token",
"X_DNS_PREFETCH_CONTROL": "X-DNS-Prefetch-Control",
"X_DOWNLOAD_OPTIONS": "X-Download-Options",
"X_FORWARDED_FOR": "X-Forwarded-For",
"X_FORWARDED_HOST": "X-Forwarded-Host",
"X_FORWARDED_PROTO": "X-Forwarded-Proto",
"X_FRAME_OPTIONS": "X-Frame-Options",
"X_HTTP_METHOD_OVERRIDE": "X-Http-Method-Override",
"X_PERMITTED_CROSS_DOMAIN_POLICIES": "X-Permitted-Cross-Domain-Policies",
"X_POWERED_BY": "X-Powered-By",
"X_REQUEST_ID": "X-Request-ID",
"X_REQUESTED_WITH": "X-Requested-With",
"X_ROBOTS_TAG": "X-Robots-Tag",
"X_UA_COMPATIBLE": "X-UA-Compatible",
"X_UIDH": "X-UIDH",
"X_WAP_PROFILE": "X-Wap-Profile",
"X_WEBKIT_CSP": "X-WebKit-CSP",
"X_XSS_PROTECTION": "X-XSS-Protection"
};
let ContentEncodings = {
"GZIP": "gzip",
"COMPRESS": "compress",
"DEFLATE": "deflate",
"IDENTITY": "identity",
"BR": "br",
"SDCH": "sdch",
"AES128GCM": "aes128gcm",
"EXI": "exi",
"PACK200_GZIP": "pack200-gzip",
"X_COMPRESS": "x-compress",
"X_GZIP": "x-gzip"
"AES128GCM": "aes128gcm",
"BR": "br",
"COMPRESS": "compress",
"DEFLATE": "deflate",
"EXI": "exi",
"GZIP": "gzip",
"IDENTITY": "identity",
"PACK200_GZIP": "pack200-gzip",
"SDCH": "sdch",
"X_COMPRESS": "x-compress",
"X_GZIP": "x-gzip"
};

@@ -431,2 +440,3 @@

module.exports.ResponseCodes = ResponseCodes;
module.exports.RespCodeIs = RespCodeIs;

@@ -433,0 +443,0 @@

{
"name": "http-headers-js",
"version": "1.0.6",
"version": "1.0.7",
"description": "Standard and common non-standard HTTP headers and MIME-types",

@@ -5,0 +5,0 @@ "main": "index.js",

+36
-11
# Standard and common HTTP headers and Mime types
> current version 1.0.6
> current version 1.0.7

@@ -40,3 +40,4 @@ Provides standard and common non-standard http headers, mime-types, methods, content codings, response statuses and tracking statuses.

ContentEncodings,
ResponseCodes
ResponseCodes,
RespCodeIs
} = require('http-headers-js');

@@ -50,4 +51,6 @@

- MimeTypes - yes, mime types, fair and square
- RespCodeIs - set of functions to get type of response code
### Constants
Import and usage, as exemplified by express js middleware

@@ -101,2 +104,18 @@

### Functions
There are 5 functions to check response code:
- `RespCodeIs.Info`
- `RespCodeIs.Success`
- `RespCodeIs.Redirect`
- `RespCodeIs.ClientErr`
- `RespCodeIs.ServerErr`
All functions take number argument, like
RespCodeIs.ServerErr(500) //return true
RespCodeIs.ServerErr(ResponseCodes.INTERNAL_SERVER_ERROR) //return true
RespCodeIs.ClientErr(ResponseCodes.USE_PROXY) //return false
## Dependencies

@@ -119,8 +138,7 @@

## What's new
### 1.0.2
- Added `Methods`
- Added `Last-Event-ID`, `DPR`, `Content-DPR`, `Accept-CH`, `Accept-CH-Lifetime`, `Width`, `Viewport-Width`, `Keep-Alive` headers
### 1.0.3
- Added `Content-Version`, `Derived-From`, `Alternates`, `MIME-Version`, `Public`, `Title` headers
- Added `ContentEncodings`
### 1.0.7
- Added `RespCodeIs`
- Headers and Methods sorted in src
### 1.0.6
- Added `ResponseCodes`
### 1.0.5

@@ -132,4 +150,8 @@ - Added `Early-Data`, `Downlink`, `Save-Data`, `Referrer-Policy`, `Content-Security-Policy-Report-Only`,

- Autotest key names
### 1.0.6
- Added `ResponseCodes`
### 1.0.3
- Added `Content-Version`, `Derived-From`, `Alternates`, `MIME-Version`, `Public`, `Title` headers
- Added `ContentEncodings`
### 1.0.2
- Added `Methods`
- Added `Last-Event-ID`, `DPR`, `Content-DPR`, `Accept-CH`, `Accept-CH-Lifetime`, `Width`, `Viewport-Width`, `Keep-Alive` headers

@@ -158,1 +180,4 @@

@@ -16,2 +16,6 @@ let { Headers } = require('http-headers-js');

console.log(ContentEncodings.DEFLATE);
console.log(ContentEncodings.DEFLATE);
let { ResponseCodes } = require('http-headers-js');
console.log(ResponseCodes.NOT_FOUND);

@@ -12,4 +12,4 @@ {

"dependencies": {
"http-headers-js": "^1.0.5"
"http-headers-js": "^1.0.6"
}
}

@@ -8,3 +8,4 @@ let chai = require('chai'),

ContentEncodings,
ResponseCodes
ResponseCodes,
RespCodeIs
} = require('../index.js');

@@ -93,2 +94,49 @@

describe("Test RespCodeIs", () => {
it ("should work with ResponseCodes", () => {
chai.expect(RespCodeIs.Info(100)).to.be.true;
chai.expect(RespCodeIs.Info(ResponseCodes.CONTINUE)).to.be.true;
chai.expect(RespCodeIs.Info(199)).to.be.true;
chai.expect(RespCodeIs.Info(ResponseCodes.EARLY_HINTS)).to.be.true;
chai.expect(RespCodeIs.Info(99)).to.be.false;
chai.expect(RespCodeIs.Info(201)).to.be.false;
chai.expect(RespCodeIs.Info(ResponseCodes.OK)).to.be.false;
chai.expect(RespCodeIs.Info(ResponseCodes.MULTIPLE_CHOICE)).to.be.false;
chai.expect(RespCodeIs.Success(200)).to.be.true;
chai.expect(RespCodeIs.Success(ResponseCodes.OK)).to.be.true;
chai.expect(RespCodeIs.Success(299)).to.be.true;
chai.expect(RespCodeIs.Success(ResponseCodes.IM_USED)).to.be.true;
chai.expect(RespCodeIs.Success(187)).to.be.false;
chai.expect(RespCodeIs.Success(301)).to.be.false;
chai.expect(RespCodeIs.Success(ResponseCodes.CONTINUE)).to.be.false;
chai.expect(RespCodeIs.Success(ResponseCodes.BAD_REQUEST)).to.be.false;
chai.expect(RespCodeIs.Redirect(300)).to.be.true;
chai.expect(RespCodeIs.Redirect(ResponseCodes.MULTIPLE_CHOICE)).to.be.true;
chai.expect(RespCodeIs.Redirect(399)).to.be.true;
chai.expect(RespCodeIs.Redirect(ResponseCodes.PERMANENT_REDIRECT)).to.be.true;
chai.expect(RespCodeIs.Redirect(187)).to.be.false;
chai.expect(RespCodeIs.Redirect(401)).to.be.false;
chai.expect(RespCodeIs.Redirect(ResponseCodes.CONTINUE)).to.be.false;
chai.expect(RespCodeIs.Redirect(ResponseCodes.BAD_REQUEST)).to.be.false;
chai.expect(RespCodeIs.ClientErr(400)).to.be.true;
chai.expect(RespCodeIs.ClientErr(ResponseCodes.BAD_REQUEST)).to.be.true;
chai.expect(RespCodeIs.ClientErr(499)).to.be.true;
chai.expect(RespCodeIs.ClientErr(ResponseCodes.UNAVAILABLE_FOR_LEGAL_REASONS)).to.be.true;
chai.expect(RespCodeIs.ClientErr(387)).to.be.false;
chai.expect(RespCodeIs.ClientErr(501)).to.be.false;
chai.expect(RespCodeIs.ClientErr(ResponseCodes.USE_PROXY)).to.be.false;
chai.expect(RespCodeIs.ClientErr(ResponseCodes.INTERNAL_SERVER_ERROR)).to.be.false;
chai.expect(RespCodeIs.ServerErr(500)).to.be.true;
chai.expect(RespCodeIs.ServerErr(ResponseCodes.INTERNAL_SERVER_ERROR)).to.be.true;
chai.expect(RespCodeIs.ServerErr(599)).to.be.true;
chai.expect(RespCodeIs.ServerErr(ResponseCodes.INVALID_SSL_CERTIFICATE)).to.be.true;
chai.expect(RespCodeIs.ServerErr(387)).to.be.false;
chai.expect(RespCodeIs.ServerErr(601)).to.be.false;
chai.expect(RespCodeIs.ServerErr(ResponseCodes.USE_PROXY)).to.be.false;
});
});

@@ -118,1 +166,2 @@