This commit is contained in:
eric sciple 2020-01-24 12:30:26 -05:00
parent 00c3b50fca
commit ae5dcb46c8
7331 changed files with 1784502 additions and 0 deletions

1
node_modules/psl/.eslintignore generated vendored Normal file
View file

@ -0,0 +1 @@
dist/

11
node_modules/psl/.eslintrc generated vendored Normal file
View file

@ -0,0 +1,11 @@
{
"rules": {
"indent": [ 2, 2 ],
"padding-line-between-statements": "off",
"hapi/hapi-no-var": false
},
"extends": "hapi",
"env": {
"mocha": true
}
}

5
node_modules/psl/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,5 @@
language: node_js
node_js:
- 8
- 10
- 12

9
node_modules/psl/LICENSE generated vendored Normal file
View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2017 Lupo Montero lupomontero@gmail.com
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.

213
node_modules/psl/README.md generated vendored Normal file
View file

@ -0,0 +1,213 @@
# psl (Public Suffix List)
[![NPM](https://nodei.co/npm/psl.png?downloads=true&downloadRank=true)](https://nodei.co/npm/psl/)
[![Greenkeeper badge](https://badges.greenkeeper.io/wrangr/psl.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/wrangr/psl.svg?branch=master)](https://travis-ci.org/wrangr/psl)
[![devDependency Status](https://david-dm.org/wrangr/psl/dev-status.png)](https://david-dm.org/wrangr/psl#info=devDependencies)
`psl` is a `JavaScript` domain name parser based on the
[Public Suffix List](https://publicsuffix.org/).
This implementation is tested against the
[test data hosted by Mozilla](http://mxr.mozilla.org/mozilla-central/source/netwerk/test/unit/data/test_psl.txt?raw=1)
and kindly provided by [Comodo](https://www.comodo.com/).
## What is the Public Suffix List?
The Public Suffix List is a cross-vendor initiative to provide an accurate list
of domain name suffixes.
The Public Suffix List is an initiative of the Mozilla Project, but is
maintained as a community resource. It is available for use in any software,
but was originally created to meet the needs of browser manufacturers.
A "public suffix" is one under which Internet users can directly register names.
Some examples of public suffixes are ".com", ".co.uk" and "pvt.k12.wy.us". The
Public Suffix List is a list of all known public suffixes.
Source: http://publicsuffix.org
## Installation
### Node.js
```sh
npm install --save psl
```
### Browser
Download [psl.min.js](https://raw.githubusercontent.com/wrangr/psl/master/dist/psl.min.js)
and include it in a script tag.
```html
<script src="psl.min.js"></script>
```
This script is browserified and wrapped in a [umd](https://github.com/umdjs/umd)
wrapper so you should be able to use it standalone or together with a module
loader.
## API
### `psl.parse(domain)`
Parse domain based on Public Suffix List. Returns an `Object` with the following
properties:
* `tld`: Top level domain (this is the _public suffix_).
* `sld`: Second level domain (the first private part of the domain name).
* `domain`: The domain name is the `sld` + `tld`.
* `subdomain`: Optional parts left of the domain.
#### Example:
```js
var psl = require('psl');
// Parse domain without subdomain
var parsed = psl.parse('google.com');
console.log(parsed.tld); // 'com'
console.log(parsed.sld); // 'google'
console.log(parsed.domain); // 'google.com'
console.log(parsed.subdomain); // null
// Parse domain with subdomain
var parsed = psl.parse('www.google.com');
console.log(parsed.tld); // 'com'
console.log(parsed.sld); // 'google'
console.log(parsed.domain); // 'google.com'
console.log(parsed.subdomain); // 'www'
// Parse domain with nested subdomains
var parsed = psl.parse('a.b.c.d.foo.com');
console.log(parsed.tld); // 'com'
console.log(parsed.sld); // 'foo'
console.log(parsed.domain); // 'foo.com'
console.log(parsed.subdomain); // 'a.b.c.d'
```
### `psl.get(domain)`
Get domain name, `sld` + `tld`. Returns `null` if not valid.
#### Example:
```js
var psl = require('psl');
// null input.
psl.get(null); // null
// Mixed case.
psl.get('COM'); // null
psl.get('example.COM'); // 'example.com'
psl.get('WwW.example.COM'); // 'example.com'
// Unlisted TLD.
psl.get('example'); // null
psl.get('example.example'); // 'example.example'
psl.get('b.example.example'); // 'example.example'
psl.get('a.b.example.example'); // 'example.example'
// TLD with only 1 rule.
psl.get('biz'); // null
psl.get('domain.biz'); // 'domain.biz'
psl.get('b.domain.biz'); // 'domain.biz'
psl.get('a.b.domain.biz'); // 'domain.biz'
// TLD with some 2-level rules.
psl.get('uk.com'); // null);
psl.get('example.uk.com'); // 'example.uk.com');
psl.get('b.example.uk.com'); // 'example.uk.com');
// More complex TLD.
psl.get('c.kobe.jp'); // null
psl.get('b.c.kobe.jp'); // 'b.c.kobe.jp'
psl.get('a.b.c.kobe.jp'); // 'b.c.kobe.jp'
psl.get('city.kobe.jp'); // 'city.kobe.jp'
psl.get('www.city.kobe.jp'); // 'city.kobe.jp'
// IDN labels.
psl.get('食狮.com.cn'); // '食狮.com.cn'
psl.get('食狮.公司.cn'); // '食狮.公司.cn'
psl.get('www.食狮.公司.cn'); // '食狮.公司.cn'
// Same as above, but punycoded.
psl.get('xn--85x722f.com.cn'); // 'xn--85x722f.com.cn'
psl.get('xn--85x722f.xn--55qx5d.cn'); // 'xn--85x722f.xn--55qx5d.cn'
psl.get('www.xn--85x722f.xn--55qx5d.cn'); // 'xn--85x722f.xn--55qx5d.cn'
```
### `psl.isValid(domain)`
Check whether a domain has a valid Public Suffix. Returns a `Boolean` indicating
whether the domain has a valid Public Suffix.
#### Example
```js
var psl = require('psl');
psl.isValid('google.com'); // true
psl.isValid('www.google.com'); // true
psl.isValid('x.yz'); // false
```
## Testing and Building
Test are written using [`mocha`](https://mochajs.org/) and can be
run in two different environments: `node` and `phantomjs`.
```sh
# This will run `eslint`, `mocha` and `karma`.
npm test
# Individual test environments
# Run tests in node only.
./node_modules/.bin/mocha test
# Run tests in phantomjs only.
./node_modules/.bin/karma start ./karma.conf.js --single-run
# Build data (parse raw list) and create dist files
npm run build
```
Feel free to fork if you see possible improvements!
## Acknowledgements
* Mozilla Foundation's [Public Suffix List](https://publicsuffix.org/)
* Thanks to Rob Stradling of [Comodo](https://www.comodo.com/) for providing
test data.
* Inspired by [weppos/publicsuffix-ruby](https://github.com/weppos/publicsuffix-ruby)
## License
The MIT License (MIT)
Copyright (c) 2017 Lupo Montero <lupomontero@gmail.com>
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.

1
node_modules/psl/data/rules.json generated vendored Normal file

File diff suppressed because one or more lines are too long

812
node_modules/psl/dist/psl.js generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/psl/dist/psl.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

269
node_modules/psl/index.js generated vendored Normal file
View file

@ -0,0 +1,269 @@
/*eslint no-var:0, prefer-arrow-callback: 0, object-shorthand: 0 */
'use strict';
var Punycode = require('punycode');
var internals = {};
//
// Read rules from file.
//
internals.rules = require('./data/rules.json').map(function (rule) {
return {
rule: rule,
suffix: rule.replace(/^(\*\.|\!)/, ''),
punySuffix: -1,
wildcard: rule.charAt(0) === '*',
exception: rule.charAt(0) === '!'
};
});
//
// Check is given string ends with `suffix`.
//
internals.endsWith = function (str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
};
//
// Find rule for a given domain.
//
internals.findRule = function (domain) {
var punyDomain = Punycode.toASCII(domain);
return internals.rules.reduce(function (memo, rule) {
if (rule.punySuffix === -1){
rule.punySuffix = Punycode.toASCII(rule.suffix);
}
if (!internals.endsWith(punyDomain, '.' + rule.punySuffix) && punyDomain !== rule.punySuffix) {
return memo;
}
// This has been commented out as it never seems to run. This is because
// sub tlds always appear after their parents and we never find a shorter
// match.
//if (memo) {
// var memoSuffix = Punycode.toASCII(memo.suffix);
// if (memoSuffix.length >= punySuffix.length) {
// return memo;
// }
//}
return rule;
}, null);
};
//
// Error codes and messages.
//
exports.errorCodes = {
DOMAIN_TOO_SHORT: 'Domain name too short.',
DOMAIN_TOO_LONG: 'Domain name too long. It should be no more than 255 chars.',
LABEL_STARTS_WITH_DASH: 'Domain name label can not start with a dash.',
LABEL_ENDS_WITH_DASH: 'Domain name label can not end with a dash.',
LABEL_TOO_LONG: 'Domain name label should be at most 63 chars long.',
LABEL_TOO_SHORT: 'Domain name label should be at least 1 character long.',
LABEL_INVALID_CHARS: 'Domain name label can only contain alphanumeric characters or dashes.'
};
//
// Validate domain name and throw if not valid.
//
// From wikipedia:
//
// Hostnames are composed of series of labels concatenated with dots, as are all
// domain names. Each label must be between 1 and 63 characters long, and the
// entire hostname (including the delimiting dots) has a maximum of 255 chars.
//
// Allowed chars:
//
// * `a-z`
// * `0-9`
// * `-` but not as a starting or ending character
// * `.` as a separator for the textual portions of a domain name
//
// * http://en.wikipedia.org/wiki/Domain_name
// * http://en.wikipedia.org/wiki/Hostname
//
internals.validate = function (input) {
// Before we can validate we need to take care of IDNs with unicode chars.
var ascii = Punycode.toASCII(input);
if (ascii.length < 1) {
return 'DOMAIN_TOO_SHORT';
}
if (ascii.length > 255) {
return 'DOMAIN_TOO_LONG';
}
// Check each part's length and allowed chars.
var labels = ascii.split('.');
var label;
for (var i = 0; i < labels.length; ++i) {
label = labels[i];
if (!label.length) {
return 'LABEL_TOO_SHORT';
}
if (label.length > 63) {
return 'LABEL_TOO_LONG';
}
if (label.charAt(0) === '-') {
return 'LABEL_STARTS_WITH_DASH';
}
if (label.charAt(label.length - 1) === '-') {
return 'LABEL_ENDS_WITH_DASH';
}
if (!/^[a-z0-9\-]+$/.test(label)) {
return 'LABEL_INVALID_CHARS';
}
}
};
//
// Public API
//
//
// Parse domain.
//
exports.parse = function (input) {
if (typeof input !== 'string') {
throw new TypeError('Domain name must be a string.');
}
// Force domain to lowercase.
var domain = input.slice(0).toLowerCase();
// Handle FQDN.
// TODO: Simply remove trailing dot?
if (domain.charAt(domain.length - 1) === '.') {
domain = domain.slice(0, domain.length - 1);
}
// Validate and sanitise input.
var error = internals.validate(domain);
if (error) {
return {
input: input,
error: {
message: exports.errorCodes[error],
code: error
}
};
}
var parsed = {
input: input,
tld: null,
sld: null,
domain: null,
subdomain: null,
listed: false
};
var domainParts = domain.split('.');
// Non-Internet TLD
if (domainParts[domainParts.length - 1] === 'local') {
return parsed;
}
var handlePunycode = function () {
if (!/xn--/.test(domain)) {
return parsed;
}
if (parsed.domain) {
parsed.domain = Punycode.toASCII(parsed.domain);
}
if (parsed.subdomain) {
parsed.subdomain = Punycode.toASCII(parsed.subdomain);
}
return parsed;
};
var rule = internals.findRule(domain);
// Unlisted tld.
if (!rule) {
if (domainParts.length < 2) {
return parsed;
}
parsed.tld = domainParts.pop();
parsed.sld = domainParts.pop();
parsed.domain = [parsed.sld, parsed.tld].join('.');
if (domainParts.length) {
parsed.subdomain = domainParts.pop();
}
return handlePunycode();
}
// At this point we know the public suffix is listed.
parsed.listed = true;
var tldParts = rule.suffix.split('.');
var privateParts = domainParts.slice(0, domainParts.length - tldParts.length);
if (rule.exception) {
privateParts.push(tldParts.shift());
}
parsed.tld = tldParts.join('.');
if (!privateParts.length) {
return handlePunycode();
}
if (rule.wildcard) {
tldParts.unshift(privateParts.pop());
parsed.tld = tldParts.join('.');
}
if (!privateParts.length) {
return handlePunycode();
}
parsed.sld = privateParts.pop();
parsed.domain = [parsed.sld, parsed.tld].join('.');
if (privateParts.length) {
parsed.subdomain = privateParts.join('.');
}
return handlePunycode();
};
//
// Get domain.
//
exports.get = function (domain) {
if (!domain) {
return null;
}
return exports.parse(domain).domain || null;
};
//
// Check whether domain belongs to a known public suffix.
//
exports.isValid = function (domain) {
var parsed = exports.parse(domain);
return Boolean(parsed.domain && parsed.listed);
};

38
node_modules/psl/karma.conf.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
'use strict';
module.exports = function (config) {
config.set({
browsers: ['PhantomJS'],
frameworks: ['browserify', 'mocha'],
files: [
'test/**/*.spec.js'
],
preprocessors: {
'test/**/*.spec.js': ['browserify']
},
reporters: ['mocha'],
client: {
mocha: {
reporter: 'tap'
}
},
plugins: [
'karma-browserify',
'karma-mocha',
'karma-mocha-reporter',
'karma-phantomjs-launcher'
]
});
};

46
node_modules/psl/package.json generated vendored Normal file
View file

@ -0,0 +1,46 @@
{
"name": "psl",
"version": "1.1.33",
"description": "Domain name parser based on the Public Suffix List",
"repository": {
"type": "git",
"url": "git@github.com:wrangr/psl.git"
},
"main": "index.js",
"scripts": {
"pretest": "eslint .",
"test": "mocha test && karma start ./karma.conf.js --single-run",
"watch": "mocha test --watch",
"prebuild": "node ./data/build.js",
"build": "browserify ./index.js --standalone=psl > ./dist/psl.js",
"postbuild": "cat ./dist/psl.js | uglifyjs -c -m > ./dist/psl.min.js",
"changelog": "git log $(git describe --tags --abbrev=0)..HEAD --oneline --format=\"%h %s (%an <%ae>)\""
},
"keywords": [
"publicsuffix",
"publicsuffixlist"
],
"author": "Lupo Montero",
"license": "MIT",
"devDependencies": {
"JSONStream": "^1.3.5",
"browserify": "^16.2.3",
"eslint": "^5.16.0",
"eslint-config-hapi": "^12.0.0",
"eslint-plugin-hapi": "^4.1.0",
"karma": "^4.1.0",
"karma-browserify": "^6.0.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"mocha": "^6.1.4",
"phantomjs-prebuilt": "^2.1.16",
"request": "^2.88.0",
"uglify-js": "^3.6.0",
"watchify": "^3.11.1"
}
,"_resolved": "https://registry.npmjs.org/psl/-/psl-1.1.33.tgz"
,"_integrity": "sha512-LTDP2uSrsc7XCb5lO7A8BI1qYxRe/8EqlRvMeEl6rsnYAqDOl8xHR+8lSAIVfrNaSAlTPTNOCgNjWcoUL3AZsw=="
,"_from": "psl@1.1.33"
}