node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

20
server/node_modules/is-localhost-ip/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright Konstantin Vyatkin <tino@vtkn.io>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

53
server/node_modules/is-localhost-ip/README.md generated vendored Normal file
View File

@@ -0,0 +1,53 @@
[![codecov](https://codecov.io/gh/tinovyatkin/is-localhost-ip/branch/master/graph/badge.svg)](https://codecov.io/gh/tinovyatkin/is-localhost-ip) ![node](https://img.shields.io/node/v/is-localhost-ip)
# is-localhost-ip
Comprehensive and robust library to checks whether given host name or IPv4/IPv6 address belongs to the local machine
Main difference from other libraries here is comprehensiveness: we start from strict RegExp checks (for IP address first, and then for correctness to be a host name), then fallback to DNS resolver (so it works with something like `john.dev` remapped locally in `hosts` or with local resolver).
All this in just _~100 lines of code_ without external dependencies.
## Installation
```sh
npm i is-localhost-ip
# or
yarn add is-localhost-ip
```
## Example
```js
const isLocalhost = require('is-localhost-ip');
(async () => {
await isLocalhost('127.0.0.1'); // true
await isLocalhost('::ffff:127.0.0.1'); // true
await isLocalhost('192.168.0.12'); // true
await isLocalhost('192.168.0.12', true); // true only if the local machine has an interface with that address
await isLocalhost('184.55.123.2'); // false
await isLocalhost('tino.local'); // true
await isLocalhost('localhost'); // true
await isLocalhost('microsoft.com'); // false
})();
```
## Caveats
Doesn't work with internationalized ([RFC 3492](https://tools.ietf.org/html/rfc3492) or [RFC 5891](https://tools.ietf.org/html/rfc5891)) domain names. If you need that please use wonderful [Punycode.js](https://github.com/bestiejs/punycode.js) to convert the string before passing to this library:
```js
const isLocalhost = require('is-localhost-ip');
const punycode = require('punycode');
(async () => {
await isLocalhost(punycode.toASCII('свобода.рф')); // false
await isLocalhost(punycode.toASCII('私の.家')); // true
})();
```
## License
`is-localhost-ip` is available under the [MIT](https://mths.be/mit) license.

7
server/node_modules/is-localhost-ip/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
/** Returns true if given parameter is local IP address or resolves into one, false otherwise */
declare async function isLocalhost(
addrOrHost: string,
canBind?: boolean,
): Promise<boolean>;
export = isLocalhost;

101
server/node_modules/is-localhost-ip/index.js generated vendored Normal file
View File

@@ -0,0 +1,101 @@
'use strict';
const { isIP, isIPv4 } = require('net');
const { createSocket } = require('dgram');
const { ADDRCONFIG } = require('dns');
const { lookup } = require('dns').promises;
/**
* Addresses reserved for private networks
* @see {@link https://en.wikipedia.org/wiki/Private_network}
* @see {@link https://en.wikipedia.org/wiki/Unique_local_address}
*/
const IP_RANGES = [
// 10.0.0.0 - 10.255.255.255
/^(:{2}f{4}:)?10(?:\.\d{1,3}){3}$/,
// 127.0.0.0 - 127.255.255.255
/^(:{2}f{4}:)?127(?:\.\d{1,3}){3}$/,
// 169.254.1.0 - 169.254.254.255
/^(::f{4}:)?169\.254\.([1-9]|1?\d\d|2[0-4]\d|25[0-4])\.\d{1,3}$/,
// 172.16.0.0 - 172.31.255.255
/^(:{2}f{4}:)?(172\.1[6-9]|172\.2\d|172\.3[01])(?:\.\d{1,3}){2}$/,
// 192.168.0.0 - 192.168.255.255
/^(:{2}f{4}:)?192\.168(?:\.\d{1,3}){2}$/,
// fc00::/7
/^f[cd][\da-f]{2}(::1$|:[\da-f]{1,4}){1,7}$/,
// fe80::/10
/^fe[89ab][\da-f](::1$|:[\da-f]{1,4}){1,7}$/,
];
// Concat all RegExes from above into one
const IP_TESTER_RE = new RegExp(
`^(${IP_RANGES.map((re) => re.source).join('|')})$`,
);
/**
* Syntax validation RegExp for possible valid host names. Permits underscore.
* Maximum total length 253 symbols, maximum segment length 63 symbols
* @see {@link https://en.wikipedia.org/wiki/Hostname}
*/
const VALID_HOSTNAME =
// eslint-disable-next-line regexp/no-dupe-disjunctions
/(?![\w-]{64})((^(?=[-\w.]{1,253}\.?$)((\w{1,63}|(\w[-\w]{0,61}\w))\.?)+$)(?<!\.{2}))/;
/**
*
* @param {string} ip
* @returns {Promise<boolean>}
*/
async function canBindToIp(ip) {
const socket = createSocket(isIPv4(ip) ? 'udp4' : 'udp6');
return new Promise((resolve) => {
try {
socket
.once('error', () => socket.close(() => resolve(false)))
.once('listening', () => socket.close(() => resolve(true)))
.unref()
.bind(0, ip);
} catch {
socket.close(() => resolve(false));
}
});
}
/**
* Checks if given strings is a local IP address or a DNS name that resolve into a local IP
*
* @param {string} ipOrHostname
* @param {boolean} [canBind=false] - should check whether an interface with such address exists on the local machine
* @returns {Promise.<boolean>} - true, if given strings is a local IP address or DNS names that resolves to local IP
*/
async function isLocalhost(ipOrHostname, canBind = false) {
if (typeof ipOrHostname !== 'string') return false;
// Check if given string is an IP address
if (isIP(ipOrHostname)) {
if (IP_TESTER_RE.test(ipOrHostname) && !canBind) return true;
return canBindToIp(ipOrHostname);
}
// May it be a hostname?
if (!VALID_HOSTNAME.test(ipOrHostname)) return false;
// it's a DNS name
try {
const addresses = await lookup(ipOrHostname, {
all: true,
family: 0,
verbatim: true,
hints: ADDRCONFIG,
});
if (!Array.isArray(addresses)) return false;
for (const { address } of addresses) {
if (await isLocalhost(address, canBind)) return true;
}
// eslint-disable-next-line no-empty
} catch {}
return false;
}
module.exports = isLocalhost;
module.exports.VALID_HOSTNAME = VALID_HOSTNAME; // for tests

59
server/node_modules/is-localhost-ip/package.json generated vendored Normal file
View File

@@ -0,0 +1,59 @@
{
"name": "is-localhost-ip",
"version": "2.0.0",
"description": "Checks whether given DNS name or IPv4/IPv6 address belongs to a local machine",
"main": "index.js",
"files": [
"index.js",
"index.d.ts"
],
"types": "index.d.ts",
"engines": {
"node": ">=12"
},
"scripts": {
"test": "jest --coverage --verbose",
"lint": "eslint ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/tinovyatkin/is-localhost-ip.git"
},
"keywords": [
"localhost",
"is-localhost",
"check-localhost",
"is-loopback",
"is-local-ip",
"ip",
"dns"
],
"author": "Konstantin Vyatkin <tino@vtkn.io>",
"license": "MIT",
"bugs": {
"url": "https://github.com/tinovyatkin/is-localhost-ip/issues"
},
"homepage": "https://github.com/tinovyatkin/is-localhost-ip#readme",
"devDependencies": {
"@types/jest": "28.1.6",
"@types/node": "~12",
"eslint": "8.21.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-regexp": "^1.8.0",
"jest": "28.1.3",
"prettier": "2.7.1"
},
"jest": {
"coverageReporters": [
"text",
"json",
"cobertura",
"lcov"
],
"coverageProvider": "v8",
"testEnvironment": "node",
"collectCoverage": true
}
}