mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-04 05:50:50 +00:00
nhj
more
This commit is contained in:
29
unified-ai-platform/node_modules/proxy-from-env/.eslintrc
generated
vendored
Normal file
29
unified-ai-platform/node_modules/proxy-from-env/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true
|
||||
},
|
||||
"rules": {
|
||||
"array-bracket-spacing": [2, "never"],
|
||||
"block-scoped-var": 2,
|
||||
"brace-style": [2, "1tbs"],
|
||||
"camelcase": 1,
|
||||
"computed-property-spacing": [2, "never"],
|
||||
"curly": 2,
|
||||
"eol-last": 2,
|
||||
"eqeqeq": [2, "smart"],
|
||||
"max-depth": [1, 3],
|
||||
"max-len": [1, 80],
|
||||
"max-statements": [1, 15],
|
||||
"new-cap": 1,
|
||||
"no-extend-native": 2,
|
||||
"no-mixed-spaces-and-tabs": 2,
|
||||
"no-trailing-spaces": 2,
|
||||
"no-unused-vars": 1,
|
||||
"no-use-before-define": [2, "nofunc"],
|
||||
"object-curly-spacing": [2, "never"],
|
||||
"quotes": [2, "single", "avoid-escape"],
|
||||
"semi": [2, "always"],
|
||||
"keyword-spacing": [2, {"before": true, "after": true}],
|
||||
"space-unary-ops": 2
|
||||
}
|
||||
}
|
||||
20
unified-ai-platform/node_modules/proxy-from-env/LICENSE
generated
vendored
Normal file
20
unified-ai-platform/node_modules/proxy-from-env/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (C) 2016-2018 Rob Wu <rob@robwu.nl>
|
||||
|
||||
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.
|
||||
108
unified-ai-platform/node_modules/proxy-from-env/index.js
generated
vendored
Normal file
108
unified-ai-platform/node_modules/proxy-from-env/index.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
'use strict';
|
||||
|
||||
var parseUrl = require('url').parse;
|
||||
|
||||
var DEFAULT_PORTS = {
|
||||
ftp: 21,
|
||||
gopher: 70,
|
||||
http: 80,
|
||||
https: 443,
|
||||
ws: 80,
|
||||
wss: 443,
|
||||
};
|
||||
|
||||
var stringEndsWith = String.prototype.endsWith || function(s) {
|
||||
return s.length <= this.length &&
|
||||
this.indexOf(s, this.length - s.length) !== -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string|object} url - The URL, or the result from url.parse.
|
||||
* @return {string} The URL of the proxy that should handle the request to the
|
||||
* given URL. If no proxy is set, this will be an empty string.
|
||||
*/
|
||||
function getProxyForUrl(url) {
|
||||
var parsedUrl = typeof url === 'string' ? parseUrl(url) : url || {};
|
||||
var proto = parsedUrl.protocol;
|
||||
var hostname = parsedUrl.host;
|
||||
var port = parsedUrl.port;
|
||||
if (typeof hostname !== 'string' || !hostname || typeof proto !== 'string') {
|
||||
return ''; // Don't proxy URLs without a valid scheme or host.
|
||||
}
|
||||
|
||||
proto = proto.split(':', 1)[0];
|
||||
// Stripping ports in this way instead of using parsedUrl.hostname to make
|
||||
// sure that the brackets around IPv6 addresses are kept.
|
||||
hostname = hostname.replace(/:\d*$/, '');
|
||||
port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
|
||||
if (!shouldProxy(hostname, port)) {
|
||||
return ''; // Don't proxy URLs that match NO_PROXY.
|
||||
}
|
||||
|
||||
var proxy =
|
||||
getEnv('npm_config_' + proto + '_proxy') ||
|
||||
getEnv(proto + '_proxy') ||
|
||||
getEnv('npm_config_proxy') ||
|
||||
getEnv('all_proxy');
|
||||
if (proxy && proxy.indexOf('://') === -1) {
|
||||
// Missing scheme in proxy, default to the requested URL's scheme.
|
||||
proxy = proto + '://' + proxy;
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a given URL should be proxied.
|
||||
*
|
||||
* @param {string} hostname - The host name of the URL.
|
||||
* @param {number} port - The effective port of the URL.
|
||||
* @returns {boolean} Whether the given URL should be proxied.
|
||||
* @private
|
||||
*/
|
||||
function shouldProxy(hostname, port) {
|
||||
var NO_PROXY =
|
||||
(getEnv('npm_config_no_proxy') || getEnv('no_proxy')).toLowerCase();
|
||||
if (!NO_PROXY) {
|
||||
return true; // Always proxy if NO_PROXY is not set.
|
||||
}
|
||||
if (NO_PROXY === '*') {
|
||||
return false; // Never proxy if wildcard is set.
|
||||
}
|
||||
|
||||
return NO_PROXY.split(/[,\s]/).every(function(proxy) {
|
||||
if (!proxy) {
|
||||
return true; // Skip zero-length hosts.
|
||||
}
|
||||
var parsedProxy = proxy.match(/^(.+):(\d+)$/);
|
||||
var parsedProxyHostname = parsedProxy ? parsedProxy[1] : proxy;
|
||||
var parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
|
||||
if (parsedProxyPort && parsedProxyPort !== port) {
|
||||
return true; // Skip if ports don't match.
|
||||
}
|
||||
|
||||
if (!/^[.*]/.test(parsedProxyHostname)) {
|
||||
// No wildcards, so stop proxying if there is an exact match.
|
||||
return hostname !== parsedProxyHostname;
|
||||
}
|
||||
|
||||
if (parsedProxyHostname.charAt(0) === '*') {
|
||||
// Remove leading wildcard.
|
||||
parsedProxyHostname = parsedProxyHostname.slice(1);
|
||||
}
|
||||
// Stop proxying if the hostname ends with the no_proxy host.
|
||||
return !stringEndsWith.call(hostname, parsedProxyHostname);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for an environment variable.
|
||||
*
|
||||
* @param {string} key - The name of the environment variable.
|
||||
* @return {string} The value of the environment variable.
|
||||
* @private
|
||||
*/
|
||||
function getEnv(key) {
|
||||
return process.env[key.toLowerCase()] || process.env[key.toUpperCase()] || '';
|
||||
}
|
||||
|
||||
exports.getProxyForUrl = getProxyForUrl;
|
||||
234
unified-ai-platform/node_modules/proxy-from-env/test.js
generated
vendored
Normal file
234
unified-ai-platform/node_modules/proxy-from-env/test.js
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
/* eslint max-statements:0 */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var parseUrl = require('url').parse;
|
||||
|
||||
var getProxyForUrl = require('./').getProxyForUrl;
|
||||
|
||||
// Runs the callback with process.env temporarily set to env.
|
||||
function runWithEnv(env, callback) {
|
||||
var originalEnv = process.env;
|
||||
process.env = env;
|
||||
try {
|
||||
callback();
|
||||
} finally {
|
||||
process.env = originalEnv;
|
||||
}
|
||||
}
|
||||
|
||||
// Defines a test case that checks whether getProxyForUrl(input) === expected.
|
||||
function testProxyUrl(env, expected, input) {
|
||||
assert(typeof env === 'object' && env !== null);
|
||||
// Copy object to make sure that the in param does not get modified between
|
||||
// the call of this function and the use of it below.
|
||||
env = JSON.parse(JSON.stringify(env));
|
||||
|
||||
var title = 'getProxyForUrl(' + JSON.stringify(input) + ')' +
|
||||
' === ' + JSON.stringify(expected);
|
||||
|
||||
// Save call stack for later use.
|
||||
var stack = {};
|
||||
Error.captureStackTrace(stack, testProxyUrl);
|
||||
// Only use the last stack frame because that shows where this function is
|
||||
// called, and that is sufficient for our purpose. No need to flood the logs
|
||||
// with an uninteresting stack trace.
|
||||
stack = stack.stack.split('\n', 2)[1];
|
||||
|
||||
it(title, function() {
|
||||
var actual;
|
||||
runWithEnv(env, function() {
|
||||
actual = getProxyForUrl(input);
|
||||
});
|
||||
if (expected === actual) {
|
||||
return; // Good!
|
||||
}
|
||||
try {
|
||||
assert.strictEqual(expected, actual); // Create a formatted error message.
|
||||
// Should not happen because previously we determined expected !== actual.
|
||||
throw new Error('assert.strictEqual passed. This is impossible!');
|
||||
} catch (e) {
|
||||
// Use the original stack trace, so we can see a helpful line number.
|
||||
e.stack = e.message + stack;
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe('getProxyForUrl', function() {
|
||||
describe('No proxy variables', function() {
|
||||
var env = {};
|
||||
testProxyUrl(env, '', 'http://example.com');
|
||||
testProxyUrl(env, '', 'https://example.com');
|
||||
testProxyUrl(env, '', 'ftp://example.com');
|
||||
});
|
||||
|
||||
describe('Invalid URLs', function() {
|
||||
var env = {};
|
||||
env.ALL_PROXY = 'http://unexpected.proxy';
|
||||
testProxyUrl(env, '', 'bogus');
|
||||
testProxyUrl(env, '', '//example.com');
|
||||
testProxyUrl(env, '', '://example.com');
|
||||
testProxyUrl(env, '', '://');
|
||||
testProxyUrl(env, '', '/path');
|
||||
testProxyUrl(env, '', '');
|
||||
testProxyUrl(env, '', 'http:');
|
||||
testProxyUrl(env, '', 'http:/');
|
||||
testProxyUrl(env, '', 'http://');
|
||||
testProxyUrl(env, '', 'prototype://');
|
||||
testProxyUrl(env, '', 'hasOwnProperty://');
|
||||
testProxyUrl(env, '', '__proto__://');
|
||||
testProxyUrl(env, '', undefined);
|
||||
testProxyUrl(env, '', null);
|
||||
testProxyUrl(env, '', {});
|
||||
testProxyUrl(env, '', {host: 'x', protocol: 1});
|
||||
testProxyUrl(env, '', {host: 1, protocol: 'x'});
|
||||
});
|
||||
|
||||
describe('http_proxy and HTTP_PROXY', function() {
|
||||
var env = {};
|
||||
env.HTTP_PROXY = 'http://http-proxy';
|
||||
|
||||
testProxyUrl(env, '', 'https://example');
|
||||
testProxyUrl(env, 'http://http-proxy', 'http://example');
|
||||
testProxyUrl(env, 'http://http-proxy', parseUrl('http://example'));
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
env.http_proxy = 'http://priority';
|
||||
testProxyUrl(env, 'http://priority', 'http://example');
|
||||
});
|
||||
|
||||
describe('http_proxy with non-sensical value', function() {
|
||||
var env = {};
|
||||
// Crazy values should be passed as-is. It is the responsibility of the
|
||||
// one who launches the application that the value makes sense.
|
||||
// TODO: Should we be stricter and perform validation?
|
||||
env.HTTP_PROXY = 'Crazy \n!() { ::// }';
|
||||
testProxyUrl(env, 'Crazy \n!() { ::// }', 'http://wow');
|
||||
|
||||
// The implementation assumes that the HTTP_PROXY environment variable is
|
||||
// somewhat reasonable, and if the scheme is missing, it is added.
|
||||
// Garbage in, garbage out some would say...
|
||||
env.HTTP_PROXY = 'crazy without colon slash slash';
|
||||
testProxyUrl(env, 'http://crazy without colon slash slash', 'http://wow');
|
||||
});
|
||||
|
||||
describe('https_proxy and HTTPS_PROXY', function() {
|
||||
var env = {};
|
||||
// Assert that there is no fall back to http_proxy
|
||||
env.HTTP_PROXY = 'http://unexpected.proxy';
|
||||
testProxyUrl(env, '', 'https://example');
|
||||
|
||||
env.HTTPS_PROXY = 'http://https-proxy';
|
||||
testProxyUrl(env, 'http://https-proxy', 'https://example');
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
env.https_proxy = 'http://priority';
|
||||
testProxyUrl(env, 'http://priority', 'https://example');
|
||||
});
|
||||
|
||||
describe('ftp_proxy', function() {
|
||||
var env = {};
|
||||
// Something else than http_proxy / https, as a sanity check.
|
||||
env.FTP_PROXY = 'http://ftp-proxy';
|
||||
|
||||
testProxyUrl(env, 'http://ftp-proxy', 'ftp://example');
|
||||
testProxyUrl(env, '', 'ftps://example');
|
||||
});
|
||||
|
||||
describe('all_proxy', function() {
|
||||
var env = {};
|
||||
env.ALL_PROXY = 'http://catch-all';
|
||||
testProxyUrl(env, 'http://catch-all', 'https://example');
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
env.all_proxy = 'http://priority';
|
||||
testProxyUrl(env, 'http://priority', 'https://example');
|
||||
});
|
||||
|
||||
describe('all_proxy without scheme', function() {
|
||||
var env = {};
|
||||
env.ALL_PROXY = 'noscheme';
|
||||
testProxyUrl(env, 'http://noscheme', 'http://example');
|
||||
testProxyUrl(env, 'https://noscheme', 'https://example');
|
||||
|
||||
// The module does not impose restrictions on the scheme.
|
||||
testProxyUrl(env, 'bogus-scheme://noscheme', 'bogus-scheme://example');
|
||||
|
||||
// But the URL should still be valid.
|
||||
testProxyUrl(env, '', 'bogus');
|
||||
});
|
||||
|
||||
describe('no_proxy empty', function() {
|
||||
var env = {};
|
||||
env.HTTPS_PROXY = 'http://proxy';
|
||||
|
||||
// NO_PROXY set but empty.
|
||||
env.NO_PROXY = '';
|
||||
testProxyUrl(env, 'http://proxy', 'https://example');
|
||||
|
||||
// No entries in NO_PROXY (comma).
|
||||
env.NO_PROXY = ',';
|
||||
testProxyUrl(env, 'http://proxy', 'https://example');
|
||||
|
||||
// No entries in NO_PROXY (whitespace).
|
||||
env.NO_PROXY = ' ';
|
||||
testProxyUrl(env, 'http://proxy', 'https://example');
|
||||
|
||||
// No entries in NO_PROXY (multiple whitespace / commas).
|
||||
env.NO_PROXY = ',\t,,,\n, ,\r';
|
||||
testProxyUrl(env, 'http://proxy', 'https://example');
|
||||
});
|
||||
|
||||
describe('no_proxy=example (single host)', function() {
|
||||
var env = {};
|
||||
env.HTTP_PROXY = 'http://proxy';
|
||||
|
||||
env.NO_PROXY = 'example';
|
||||
testProxyUrl(env, '', 'http://example');
|
||||
testProxyUrl(env, '', 'http://example:80');
|
||||
testProxyUrl(env, '', 'http://example:0');
|
||||
testProxyUrl(env, '', 'http://example:1337');
|
||||
testProxyUrl(env, 'http://proxy', 'http://sub.example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://prefexample');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example.no');
|
||||
testProxyUrl(env, 'http://proxy', 'http://a.b.example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://host/example');
|
||||
});
|
||||
|
||||
describe('no_proxy=sub.example (subdomain)', function() {
|
||||
var env = {};
|
||||
env.HTTP_PROXY = 'http://proxy';
|
||||
|
||||
env.NO_PROXY = 'sub.example';
|
||||
testProxyUrl(env, 'http://proxy', 'http://example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example:80');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example:0');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example:1337');
|
||||
testProxyUrl(env, '', 'http://sub.example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://no.sub.example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://sub-example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example.sub');
|
||||
});
|
||||
|
||||
describe('no_proxy=example:80 (host + port)', function() {
|
||||
var env = {};
|
||||
env.HTTP_PROXY = 'http://proxy';
|
||||
|
||||
env.NO_PROXY = 'example:80';
|
||||
testProxyUrl(env, '', 'http://example');
|
||||
testProxyUrl(env, '', 'http://example:80');
|
||||
testProxyUrl(env, '', 'http://example:0');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example:1337');
|
||||
testProxyUrl(env, 'http://proxy', 'http://sub.example');
|
||||
testProxyUrl(env, 'http://proxy', 'http://prefexample');
|
||||
testProxyUrl(env, 'http://proxy', 'http://example.no');
|
||||
testProxyUrl(env, 'http://proxy', 'http://a.b.example');
|
||||
});
|
||||
|
||||
describe('no_proxy=.example (host suffix)', function() {
|
||||
var env = {};
|
||||
env.HTTP_PROXY = 'http://proxy';
|
||||
|
||||
env.NO_PROXY = '.example';
|
||||
testProxyUrl(env, 'http:
|
||||
Reference in New Issue
Block a user