Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/request

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/request - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

3

build/src/Request.d.ts

@@ -9,3 +9,3 @@ /// <reference types="node" />

trustProxy: (address: string, distance: number) => boolean;
getIp: (request: RequestContract) => string;
getIp: ((request: RequestContract) => string) | null;
subdomainOffset: number;

@@ -24,3 +24,2 @@ };

private _lazyAccepts;
private _trustFn;
protected static _macros: {};

@@ -27,0 +26,0 @@ protected static _getters: {};

@@ -14,2 +14,9 @@ "use strict";

const macroable_1 = require("macroable");
const utils_1 = require("@adonisjs/utils");
const $ = new utils_1.ConfigReader({
allowMethodSpoofing: false,
trustProxy: proxyaddr.compile('loopback'),
getIp: null,
subdomainOffset: 2,
});
class Request extends macroable_1.Macroable {

@@ -28,3 +35,2 @@ constructor(request, response, _config) {

this._lazyAccepts = null;
this._trustFn = this._config.trustProxy || proxyaddr.compile('loopback');
this._parseQueryString();

@@ -87,3 +93,3 @@ }

method() {
if (this._config.allowMethodSpoofing && this.intended() === 'POST') {
if ($.get(this._config, 'allowMethodSpoofing') && this.intended() === 'POST') {
return this.input('_method', this.intended()).toUpperCase();

@@ -108,14 +114,14 @@ }

ip() {
const ipFn = this._config.getIp;
const ipFn = $.get(this._config, 'getIp');
if (typeof (ipFn) === 'function') {
return ipFn(this);
}
return proxyaddr(this.request, this._trustFn);
return proxyaddr(this.request, $.get(this._config, 'trustProxy'));
}
ips() {
return proxyaddr.all(this.request, this._trustFn);
return proxyaddr.all(this.request, $.get(this._config, 'trustProxy'));
}
protocol() {
const protocol = this.parsedUrl.protocol;
if (!this._trustFn(this.request.connection.remoteAddress, 0)) {
if (!$.get(this._config, 'trustProxy')(this.request.connection.remoteAddress, 0)) {
return protocol;

@@ -131,3 +137,3 @@ }

let host = this.header('host');
if (this._trustFn(this.request.connection.remoteAddress, 0)) {
if ($.get(this._config, 'trustProxy')(this.request.connection.remoteAddress, 0)) {
host = this.header('X-Forwarded-Host') || host;

@@ -147,3 +153,3 @@ }

}
const offset = this._config.subdomainOffset || 2;
const offset = $.get(this._config, 'subdomainOffset');
const subdomains = hostname.split('.').reverse().slice(offset);

@@ -150,0 +156,0 @@ if (subdomains[subdomains.length - 1] === 'www') {

@@ -6,2 +6,13 @@ # Change Log

## [1.1.3](https://github.com/adonisjs/adonis-framework/tree/master/packages/request/compare/@adonisjs/request@1.1.2...@adonisjs/request@1.1.3) (2019-01-23)
### Performance Improvements
* **request:** use config reader for simple config management ([c096966](https://github.com/adonisjs/adonis-framework/tree/master/packages/request/commit/c096966))
## [1.1.2](https://github.com/adonisjs/adonis-framework/tree/master/packages/request/compare/@adonisjs/request@1.1.1...@adonisjs/request@1.1.2) (2019-01-22)

@@ -8,0 +19,0 @@

{
"name": "@adonisjs/request",
"version": "1.1.2",
"version": "1.1.3",
"description": "Facade over Node.js HTTP req object",

@@ -36,2 +36,3 @@ "main": "build/index.js",

"dependencies": {
"@adonisjs/utils": "^1.1.0",
"accepts": "^1.3.5",

@@ -58,3 +59,3 @@ "fresh": "^0.5.2",

},
"gitHead": "54e1ee333c22484ad4fd114846cbc620b80f62ff"
"gitHead": "bb97e711a4ced5e128cf6b8002b255383c93702d"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc