summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/http2-wrapper/source/utils
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/http2-wrapper/source/utils
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/http2-wrapper/source/utils')
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/calculate-server-name.js29
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/check-type.js20
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/delay-async-destroy.js33
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/errors.js51
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.js13
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/js-stream-socket.js8
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-events.js7
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js102
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-name.js11
-rw-r--r--includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-value.js17
10 files changed, 291 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/calculate-server-name.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/calculate-server-name.js
new file mode 100644
index 0000000..a8ba061
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/calculate-server-name.js
@@ -0,0 +1,29 @@
+'use strict';
+const {isIP} = require('net');
+const assert = require('assert');
+
+const getHost = host => {
+ if (host[0] === '[') {
+ const idx = host.indexOf(']');
+
+ assert(idx !== -1);
+ return host.slice(1, idx);
+ }
+
+ const idx = host.indexOf(':');
+ if (idx === -1) {
+ return host;
+ }
+
+ return host.slice(0, idx);
+};
+
+module.exports = host => {
+ const servername = getHost(host);
+
+ if (isIP(servername)) {
+ return '';
+ }
+
+ return servername;
+};
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/check-type.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/check-type.js
new file mode 100644
index 0000000..ddfefdc
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/check-type.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const checkType = (name, value, types) => {
+ const valid = types.some(type => {
+ const typeofType = typeof type;
+ if (typeofType === 'string') {
+ return typeof value === type;
+ }
+
+ return value instanceof type;
+ });
+
+ if (!valid) {
+ const names = types.map(type => typeof type === 'string' ? type : type.name);
+
+ throw new TypeError(`Expected '${name}' to be a type of ${names.join(' or ')}, got ${typeof value}`);
+ }
+};
+
+module.exports = checkType;
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/delay-async-destroy.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/delay-async-destroy.js
new file mode 100644
index 0000000..53d81cf
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/delay-async-destroy.js
@@ -0,0 +1,33 @@
+'use strict';
+
+module.exports = stream => {
+ if (stream.listenerCount('error') !== 0) {
+ return stream;
+ }
+
+ stream.__destroy = stream._destroy;
+ stream._destroy = (...args) => {
+ const callback = args.pop();
+
+ stream.__destroy(...args, async error => {
+ await Promise.resolve();
+ callback(error);
+ });
+ };
+
+ const onError = error => {
+ // eslint-disable-next-line promise/prefer-await-to-then
+ Promise.resolve().then(() => {
+ stream.emit('error', error);
+ });
+ };
+
+ stream.once('error', onError);
+
+ // eslint-disable-next-line promise/prefer-await-to-then
+ Promise.resolve().then(() => {
+ stream.off('error', onError);
+ });
+
+ return stream;
+};
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/errors.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/errors.js
new file mode 100644
index 0000000..7be9e6b
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/errors.js
@@ -0,0 +1,51 @@
+'use strict';
+/* istanbul ignore file: https://github.com/nodejs/node/blob/master/lib/internal/errors.js */
+
+const makeError = (Base, key, getMessage) => {
+ module.exports[key] = class NodeError extends Base {
+ constructor(...args) {
+ super(typeof getMessage === 'string' ? getMessage : getMessage(args));
+ this.name = `${super.name} [${key}]`;
+ this.code = key;
+ }
+ };
+};
+
+makeError(TypeError, 'ERR_INVALID_ARG_TYPE', args => {
+ const type = args[0].includes('.') ? 'property' : 'argument';
+
+ let valid = args[1];
+ const isManyTypes = Array.isArray(valid);
+
+ if (isManyTypes) {
+ valid = `${valid.slice(0, -1).join(', ')} or ${valid.slice(-1)}`;
+ }
+
+ return `The "${args[0]}" ${type} must be ${isManyTypes ? 'one of' : 'of'} type ${valid}. Received ${typeof args[2]}`;
+});
+
+makeError(TypeError, 'ERR_INVALID_PROTOCOL', args =>
+ `Protocol "${args[0]}" not supported. Expected "${args[1]}"`
+);
+
+makeError(Error, 'ERR_HTTP_HEADERS_SENT', args =>
+ `Cannot ${args[0]} headers after they are sent to the client`
+);
+
+makeError(TypeError, 'ERR_INVALID_HTTP_TOKEN', args =>
+ `${args[0]} must be a valid HTTP token [${args[1]}]`
+);
+
+makeError(TypeError, 'ERR_HTTP_INVALID_HEADER_VALUE', args =>
+ `Invalid value "${args[0]} for header "${args[1]}"`
+);
+
+makeError(TypeError, 'ERR_INVALID_CHAR', args =>
+ `Invalid character in ${args[0]} [${args[1]}]`
+);
+
+makeError(
+ Error,
+ 'ERR_HTTP2_NO_SOCKET_MANIPULATION',
+ 'HTTP/2 sockets should not be directly manipulated (e.g. read and written)'
+);
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.js
new file mode 100644
index 0000000..bed31cd
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/is-request-pseudo-header.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = header => {
+ switch (header) {
+ case ':method':
+ case ':scheme':
+ case ':authority':
+ case ':path':
+ return true;
+ default:
+ return false;
+ }
+};
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/js-stream-socket.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/js-stream-socket.js
new file mode 100644
index 0000000..ac22280
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/js-stream-socket.js
@@ -0,0 +1,8 @@
+'use strict';
+const stream = require('stream');
+const tls = require('tls');
+
+// Really awesome hack.
+const JSStreamSocket = (new tls.TLSSocket(new stream.PassThrough()))._handle._parentWrap.constructor;
+
+module.exports = JSStreamSocket;
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-events.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-events.js
new file mode 100644
index 0000000..35e2ae0
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-events.js
@@ -0,0 +1,7 @@
+'use strict';
+
+module.exports = (from, to, events) => {
+ for (const event of events) {
+ from.on(event, (...args) => to.emit(event, ...args));
+ }
+};
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js
new file mode 100644
index 0000000..89a0ac4
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/proxy-socket-handler.js
@@ -0,0 +1,102 @@
+'use strict';
+const {ERR_HTTP2_NO_SOCKET_MANIPULATION} = require('./errors.js');
+
+/* istanbul ignore file */
+/* https://github.com/nodejs/node/blob/6eec858f34a40ffa489c1ec54bb24da72a28c781/lib/internal/http2/compat.js#L195-L272 */
+
+const proxySocketHandler = {
+ has(stream, property) {
+ // Replaced [kSocket] with .socket
+ const reference = stream.session === undefined ? stream : stream.session.socket;
+ return (property in stream) || (property in reference);
+ },
+
+ get(stream, property) {
+ switch (property) {
+ case 'on':
+ case 'once':
+ case 'end':
+ case 'emit':
+ case 'destroy':
+ return stream[property].bind(stream);
+ case 'writable':
+ case 'destroyed':
+ return stream[property];
+ case 'readable':
+ if (stream.destroyed) {
+ return false;
+ }
+
+ return stream.readable;
+ case 'setTimeout': {
+ const {session} = stream;
+ if (session !== undefined) {
+ return session.setTimeout.bind(session);
+ }
+
+ return stream.setTimeout.bind(stream);
+ }
+
+ case 'write':
+ case 'read':
+ case 'pause':
+ case 'resume':
+ throw new ERR_HTTP2_NO_SOCKET_MANIPULATION();
+ default: {
+ // Replaced [kSocket] with .socket
+ const reference = stream.session === undefined ? stream : stream.session.socket;
+ const value = reference[property];
+
+ return typeof value === 'function' ? value.bind(reference) : value;
+ }
+ }
+ },
+
+ getPrototypeOf(stream) {
+ if (stream.session !== undefined) {
+ // Replaced [kSocket] with .socket
+ return Reflect.getPrototypeOf(stream.session.socket);
+ }
+
+ return Reflect.getPrototypeOf(stream);
+ },
+
+ set(stream, property, value) {
+ switch (property) {
+ case 'writable':
+ case 'readable':
+ case 'destroyed':
+ case 'on':
+ case 'once':
+ case 'end':
+ case 'emit':
+ case 'destroy':
+ stream[property] = value;
+ return true;
+ case 'setTimeout': {
+ const {session} = stream;
+ if (session === undefined) {
+ stream.setTimeout = value;
+ } else {
+ session.setTimeout = value;
+ }
+
+ return true;
+ }
+
+ case 'write':
+ case 'read':
+ case 'pause':
+ case 'resume':
+ throw new ERR_HTTP2_NO_SOCKET_MANIPULATION();
+ default: {
+ // Replaced [kSocket] with .socket
+ const reference = stream.session === undefined ? stream : stream.session.socket;
+ reference[property] = value;
+ return true;
+ }
+ }
+ }
+};
+
+module.exports = proxySocketHandler;
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-name.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-name.js
new file mode 100644
index 0000000..82cbc34
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-name.js
@@ -0,0 +1,11 @@
+'use strict';
+const {ERR_INVALID_HTTP_TOKEN} = require('./errors.js');
+const isRequestPseudoHeader = require('./is-request-pseudo-header.js');
+
+const isValidHttpToken = /^[\^`\-\w!#$%&*+.|~]+$/;
+
+module.exports = name => {
+ if (typeof name !== 'string' || (!isValidHttpToken.test(name) && !isRequestPseudoHeader(name))) {
+ throw new ERR_INVALID_HTTP_TOKEN('Header name', name);
+ }
+};
diff --git a/includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-value.js b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-value.js
new file mode 100644
index 0000000..749c985
--- /dev/null
+++ b/includes/external/addressbook/node_modules/http2-wrapper/source/utils/validate-header-value.js
@@ -0,0 +1,17 @@
+'use strict';
+const {
+ ERR_HTTP_INVALID_HEADER_VALUE,
+ ERR_INVALID_CHAR
+} = require('./errors.js');
+
+const isInvalidHeaderValue = /[^\t\u0020-\u007E\u0080-\u00FF]/;
+
+module.exports = (name, value) => {
+ if (typeof value === 'undefined') {
+ throw new ERR_HTTP_INVALID_HEADER_VALUE(value, name);
+ }
+
+ if (isInvalidHeaderValue.test(value)) {
+ throw new ERR_INVALID_CHAR('header content', name);
+ }
+};