Firebase Update

This commit is contained in:
Lukas Nowy
2018-12-22 23:30:39 +01:00
parent befb44764d
commit acffe619b3
11523 changed files with 1614327 additions and 930246 deletions

View File

@ -1,3 +1,33 @@
2.0.4 / 2018-07-26
==================
* deps: ipaddr.js@1.8.0
2.0.3 / 2018-02-19
==================
* deps: ipaddr.js@1.6.0
2.0.2 / 2017-09-24
==================
* deps: forwarded@~0.1.2
- perf: improve header parsing
- perf: reduce overhead when no `X-Forwarded-For` header
2.0.1 / 2017-09-10
==================
* deps: forwarded@~0.1.1
- Fix trimming leading / trailing OWS
- perf: hoist regular expression
* deps: ipaddr.js@1.5.2
2.0.0 / 2017-08-08
==================
* Drop support for Node.js below 0.10
1.1.5 / 2017-07-25
==================

View File

@ -20,6 +20,8 @@ $ npm install proxy-addr
## API
<!-- eslint-disable no-unused-vars -->
```js
var proxyaddr = require('proxy-addr')
```
@ -32,15 +34,19 @@ The `trust` argument is a function that returns `true` if you trust
the address, `false` if you don't. The closest untrusted address is
returned.
<!-- eslint-disable no-undef -->
```js
proxyaddr(req, function(addr){ return addr === '127.0.0.1' })
proxyaddr(req, function(addr, i){ return i < 1 })
proxyaddr(req, function (addr) { return addr === '127.0.0.1' })
proxyaddr(req, function (addr, i) { return i < 1 })
```
The `trust` arugment may also be a single IP address string or an
array of trusted addresses, as plain IP addresses, CIDR-formatted
strings, or IP/netmask strings.
<!-- eslint-disable no-undef -->
```js
proxyaddr(req, '127.0.0.1')
proxyaddr(req, ['127.0.0.0/8', '10.0.0.0/8'])
@ -50,6 +56,8 @@ proxyaddr(req, ['127.0.0.0/255.0.0.0', '192.168.0.0/255.255.0.0'])
This module also supports IPv6. Your IPv6 addresses will be normalized
automatically (i.e. `fe80::00ed:1` equals `fe80:0:0:0:0:0:ed:1`).
<!-- eslint-disable no-undef -->
```js
proxyaddr(req, '::1')
proxyaddr(req, ['::1/128', 'fe80::/10'])
@ -62,6 +70,8 @@ not have to specify both `::ffff:a00:1` and `10.0.0.1`.
As a convenience, this module also takes certain pre-defined names
in addition to IP addresses, which expand into IP addresses:
<!-- eslint-disable no-undef -->
```js
proxyaddr(req, 'loopback')
proxyaddr(req, ['loopback', 'fc00:ac:1ab5:fff::1/64'])
@ -86,6 +96,8 @@ Return all the addresses of the request, optionally stopping at the
first untrusted. This array is ordered from closest to furthest
(i.e. `arr[0] === req.connection.remoteAddress`).
<!-- eslint-disable no-undef -->
```js
proxyaddr.all(req)
```
@ -93,6 +105,8 @@ proxyaddr.all(req)
The optional `trust` argument takes the same arguments as `trust`
does in `proxyaddr(req, trust)`.
<!-- eslint-disable no-undef -->
```js
proxyaddr.all(req, 'loopback')
```
@ -103,9 +117,11 @@ Compiles argument `val` into a `trust` function. This function takes
the same arguments as `trust` does in `proxyaddr(req, trust)` and
returns a function suitable for `proxyaddr(req, trust)`.
<!-- eslint-disable no-undef, no-unused-vars -->
```js
var trust = proxyaddr.compile('localhost')
var addr = proxyaddr(req, trust)
var trust = proxyaddr.compile('loopback')
var addr = proxyaddr(req, trust)
```
This function is meant to be optimized for use against every request.

View File

@ -11,37 +11,37 @@
* @public
*/
module.exports = proxyaddr;
module.exports.all = alladdrs;
module.exports.compile = compile;
module.exports = proxyaddr
module.exports.all = alladdrs
module.exports.compile = compile
/**
* Module dependencies.
* @private
*/
var forwarded = require('forwarded');
var ipaddr = require('ipaddr.js');
var forwarded = require('forwarded')
var ipaddr = require('ipaddr.js')
/**
* Variables.
* @private
*/
var digitre = /^[0-9]+$/;
var isip = ipaddr.isValid;
var parseip = ipaddr.parse;
var DIGIT_REGEXP = /^[0-9]+$/
var isip = ipaddr.isValid
var parseip = ipaddr.parse
/**
* Pre-defined IP ranges.
* @private
*/
var ipranges = {
var IP_RANGES = {
linklocal: ['169.254.0.0/16', 'fe80::/10'],
loopback: ['127.0.0.1/8', '::1/128'],
uniquelocal: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7']
};
}
/**
* Get all addresses in the request, optionally stopping
@ -52,26 +52,26 @@ var ipranges = {
* @public
*/
function alladdrs(req, trust) {
function alladdrs (req, trust) {
// get addresses
var addrs = forwarded(req);
var addrs = forwarded(req)
if (!trust) {
// Return all addresses
return addrs;
return addrs
}
if (typeof trust !== 'function') {
trust = compile(trust);
trust = compile(trust)
}
for (var i = 0; i < addrs.length - 1; i++) {
if (trust(addrs[i], i)) continue;
if (trust(addrs[i], i)) continue
addrs.length = i + 1;
addrs.length = i + 1
}
return addrs;
return addrs
}
/**
@ -81,35 +81,35 @@ function alladdrs(req, trust) {
* @private
*/
function compile(val) {
function compile (val) {
if (!val) {
throw new TypeError('argument is required');
throw new TypeError('argument is required')
}
var trust;
var trust
if (typeof val === 'string') {
trust = [val];
trust = [val]
} else if (Array.isArray(val)) {
trust = val.slice();
trust = val.slice()
} else {
throw new TypeError('unsupported trust argument');
throw new TypeError('unsupported trust argument')
}
for (var i = 0; i < trust.length; i++) {
val = trust[i];
val = trust[i]
if (!ipranges.hasOwnProperty(val)) {
continue;
if (!IP_RANGES.hasOwnProperty(val)) {
continue
}
// Splice in pre-defined range
val = ipranges[val];
trust.splice.apply(trust, [i, 1].concat(val));
i += val.length - 1;
val = IP_RANGES[val]
trust.splice.apply(trust, [i, 1].concat(val))
i += val.length - 1
}
return compileTrust(compileRangeSubnets(trust));
return compileTrust(compileRangeSubnets(trust))
}
/**
@ -119,14 +119,14 @@ function compile(val) {
* @private
*/
function compileRangeSubnets(arr) {
var rangeSubnets = new Array(arr.length);
function compileRangeSubnets (arr) {
var rangeSubnets = new Array(arr.length)
for (var i = 0; i < arr.length; i++) {
rangeSubnets[i] = parseipNotation(arr[i]);
rangeSubnets[i] = parseipNotation(arr[i])
}
return rangeSubnets;
return rangeSubnets
}
/**
@ -136,14 +136,14 @@ function compileRangeSubnets(arr) {
* @private
*/
function compileTrust(rangeSubnets) {
function compileTrust (rangeSubnets) {
// Return optimized function based on length
var len = rangeSubnets.length;
var len = rangeSubnets.length
return len === 0
? trustNone
: len === 1
? trustSingle(rangeSubnets[0])
: trustMulti(rangeSubnets);
? trustSingle(rangeSubnets[0])
: trustMulti(rangeSubnets)
}
/**
@ -153,46 +153,46 @@ function compileTrust(rangeSubnets) {
* @private
*/
function parseipNotation(note) {
var pos = note.lastIndexOf('/');
function parseipNotation (note) {
var pos = note.lastIndexOf('/')
var str = pos !== -1
? note.substring(0, pos)
: note;
: note
if (!isip(str)) {
throw new TypeError('invalid IP address: ' + str);
throw new TypeError('invalid IP address: ' + str)
}
var ip = parseip(str);
var ip = parseip(str)
if (pos === -1 && ip.kind() === 'ipv6' && ip.isIPv4MappedAddress()) {
// Store as IPv4
ip = ip.toIPv4Address();
ip = ip.toIPv4Address()
}
var max = ip.kind() === 'ipv6'
? 128
: 32;
: 32
var range = pos !== -1
? note.substring(pos + 1, note.length)
: null;
: null
if (range === null) {
range = max;
} else if (digitre.test(range)) {
range = parseInt(range, 10);
range = max
} else if (DIGIT_REGEXP.test(range)) {
range = parseInt(range, 10)
} else if (ip.kind() === 'ipv4' && isip(range)) {
range = parseNetmask(range);
range = parseNetmask(range)
} else {
range = null;
range = null
}
if (range <= 0 || range > max) {
throw new TypeError('invalid range on address: ' + note);
throw new TypeError('invalid range on address: ' + note)
}
return [ip, range];
return [ip, range]
}
/**
@ -202,13 +202,13 @@ function parseipNotation(note) {
* @private
*/
function parseNetmask(netmask) {
var ip = parseip(netmask);
var kind = ip.kind();
function parseNetmask (netmask) {
var ip = parseip(netmask)
var kind = ip.kind()
return kind === 'ipv4'
? ip.prefixLengthFromSubnetMask()
: null;
: null
}
/**
@ -219,19 +219,19 @@ function parseNetmask(netmask) {
* @public
*/
function proxyaddr(req, trust) {
function proxyaddr (req, trust) {
if (!req) {
throw new TypeError('req argument is required');
throw new TypeError('req argument is required')
}
if (!trust) {
throw new TypeError('trust argument is required');
throw new TypeError('trust argument is required')
}
var addrs = alladdrs(req, trust);
var addr = addrs[addrs.length - 1];
var addrs = alladdrs(req, trust)
var addr = addrs[addrs.length - 1]
return addr;
return addr
}
/**
@ -240,8 +240,8 @@ function proxyaddr(req, trust) {
* @private
*/
function trustNone() {
return false;
function trustNone () {
return false
}
/**
@ -251,44 +251,44 @@ function trustNone() {
* @private
*/
function trustMulti(subnets) {
return function trust(addr) {
if (!isip(addr)) return false;
function trustMulti (subnets) {
return function trust (addr) {
if (!isip(addr)) return false
var ip = parseip(addr);
var ipconv;
var kind = ip.kind();
var ip = parseip(addr)
var ipconv
var kind = ip.kind()
for (var i = 0; i < subnets.length; i++) {
var subnet = subnets[i];
var subnetip = subnet[0];
var subnetkind = subnetip.kind();
var subnetrange = subnet[1];
var trusted = ip;
var subnet = subnets[i]
var subnetip = subnet[0]
var subnetkind = subnetip.kind()
var subnetrange = subnet[1]
var trusted = ip
if (kind !== subnetkind) {
if (subnetkind === 'ipv4' && !ip.isIPv4MappedAddress()) {
// Incompatible IP addresses
continue;
continue
}
if (!ipconv) {
// Convert IP to match subnet IP kind
ipconv = subnetkind === 'ipv4'
? ip.toIPv4Address()
: ip.toIPv4MappedAddress();
: ip.toIPv4MappedAddress()
}
trusted = ipconv;
trusted = ipconv
}
if (trusted.match(subnetip, subnetrange)) {
return true;
return true
}
}
return false;
};
return false
}
}
/**
@ -298,30 +298,30 @@ function trustMulti(subnets) {
* @private
*/
function trustSingle(subnet) {
var subnetip = subnet[0];
var subnetkind = subnetip.kind();
var subnetisipv4 = subnetkind === 'ipv4';
var subnetrange = subnet[1];
function trustSingle (subnet) {
var subnetip = subnet[0]
var subnetkind = subnetip.kind()
var subnetisipv4 = subnetkind === 'ipv4'
var subnetrange = subnet[1]
return function trust(addr) {
if (!isip(addr)) return false;
return function trust (addr) {
if (!isip(addr)) return false
var ip = parseip(addr);
var kind = ip.kind();
var ip = parseip(addr)
var kind = ip.kind()
if (kind !== subnetkind) {
if (subnetisipv4 && !ip.isIPv4MappedAddress()) {
// Incompatible IP addresses
return false;
return false
}
// Convert IP to match subnet IP kind
ip = subnetisipv4
? ip.toIPv4Address()
: ip.toIPv4MappedAddress();
: ip.toIPv4MappedAddress()
}
return ip.match(subnetip, subnetrange);
};
return ip.match(subnetip, subnetrange)
}
}

View File

@ -1,27 +1,27 @@
{
"_from": "proxy-addr@~1.1.5",
"_id": "proxy-addr@1.1.5",
"_from": "proxy-addr@~2.0.4",
"_id": "proxy-addr@2.0.4",
"_inBundle": false,
"_integrity": "sha1-ccDuOxAt4/IC87ZPYI0XP8uhqRg=",
"_integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==",
"_location": "/proxy-addr",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "proxy-addr@~1.1.5",
"raw": "proxy-addr@~2.0.4",
"name": "proxy-addr",
"escapedName": "proxy-addr",
"rawSpec": "~1.1.5",
"rawSpec": "~2.0.4",
"saveSpec": null,
"fetchSpec": "~1.1.5"
"fetchSpec": "~2.0.4"
},
"_requiredBy": [
"/express"
],
"_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-1.1.5.tgz",
"_shasum": "71c0ee3b102de3f202f3b64f608d173fcba1a918",
"_spec": "proxy-addr@~1.1.5",
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\express-server\\node_modules\\express",
"_resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz",
"_shasum": "ecfc733bf22ff8c6f407fa275327b9ab67e48b93",
"_spec": "proxy-addr@~2.0.4",
"_where": "D:\\Desktop\\smartshopperNodeReworkFirebase\\node_modules\\express",
"author": {
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
@ -31,19 +31,26 @@
},
"bundleDependencies": false,
"dependencies": {
"forwarded": "~0.1.0",
"ipaddr.js": "1.4.0"
"forwarded": "~0.1.2",
"ipaddr.js": "1.8.0"
},
"deprecated": false,
"description": "Determine address of proxied request",
"devDependencies": {
"beautify-benchmark": "0.2.4",
"benchmark": "2.1.4",
"istanbul": "0.4.5",
"mocha": "~1.21.5"
"eslint": "4.19.1",
"eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.13.0",
"eslint-plugin-markdown": "1.0.0-beta.6",
"eslint-plugin-node": "6.0.1",
"eslint-plugin-promise": "3.8.0",
"eslint-plugin-standard": "3.1.0",
"mocha": "3.5.3",
"nyc": "10.3.2"
},
"engines": {
"node": ">= 0.6"
"node": ">= 0.10"
},
"files": [
"LICENSE",
@ -65,9 +72,10 @@
},
"scripts": {
"bench": "node benchmark/index.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
"test-cov": "nyc --reporter=text npm test",
"test-travis": "nyc --reporter=html --reporter=text npm test"
},
"version": "1.1.5"
"version": "2.0.4"
}