Upgrade node_modules for web build

This commit is contained in:
John Colvin committed 2021-10-10 12:01:07 -05:00
1 parent 6a53c8c587
commit 5d2136faee
55430 files changed
+4714852 -3372773

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
# sc-errors
Error types for SocketCluster
+79
View File
@@ -0,0 +1,79 @@
// Based on https://github.com/dscape/cycle/blob/master/cycle.js
module.exports = function decycle(object) {
// Make a deep copy of an object or array, assuring that there is at most
// one instance of each object or array in the resulting structure. The
// duplicate references (which might be forming cycles) are replaced with
// an object of the form
// {$ref: PATH}
// where the PATH is a JSONPath string that locates the first occurance.
// So,
// var a = [];
// a[0] = a;
// return JSON.stringify(JSON.decycle(a));
// produces the string '[{"$ref":"$"}]'.
// JSONPath is used to locate the unique object. $ indicates the top level of
// the object or array. [NUMBER] or [STRING] indicates a child member or
// property.
var objects = [], // Keep a reference to each unique object or array
paths = []; // Keep the path to each unique object or array
return (function derez(value, path) {
// The derez recurses through the object, producing the deep copy.
var i, // The loop counter
name, // Property name
nu; // The new object or array
// typeof null === 'object', so go on if this value is really an object but not
// one of the weird builtin objects.
if (typeof value === 'object' && value !== null &&
!(value instanceof Boolean) &&
!(value instanceof Date) &&
!(value instanceof Number) &&
!(value instanceof RegExp) &&
!(value instanceof String)) {
// If the value is an object or array, look to see if we have already
// encountered it. If so, return a $ref/path object. This is a hard way,
// linear search that will get slower as the number of unique objects grows.
for (i = 0; i < objects.length; i += 1) {
if (objects[i] === value) {
return {$ref: paths[i]};
}
}
// Otherwise, accumulate the unique value and its path.
objects.push(value);
paths.push(path);
// If it is an array, replicate the array.
if (Object.prototype.toString.apply(value) === '[object Array]') {
nu = [];
for (i = 0; i < value.length; i += 1) {
nu[i] = derez(value[i], path + '[' + i + ']');
}
} else {
// If it is an object, replicate the object.
nu = {};
for (name in value) {
if (Object.prototype.hasOwnProperty.call(value, name)) {
nu[name] = derez(value[name],
path + '[' + JSON.stringify(name) + ']');
}
}
}
return nu;
}
return value;
}(object, '$'));
};
+326
View File
@@ -0,0 +1,326 @@
var decycle = require('./decycle');
var isStrict = (function () { return !this; })();
function AuthTokenExpiredError(message, expiry) {
this.name = 'AuthTokenExpiredError';
this.message = message;
this.expiry = expiry;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
AuthTokenExpiredError.prototype = Object.create(Error.prototype);
function AuthTokenInvalidError(message) {
this.name = 'AuthTokenInvalidError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
AuthTokenInvalidError.prototype = Object.create(Error.prototype);
function AuthTokenNotBeforeError(message, date) {
this.name = 'AuthTokenNotBeforeError';
this.message = message;
this.date = date;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
AuthTokenNotBeforeError.prototype = Object.create(Error.prototype);
// For any other auth token error.
function AuthTokenError(message) {
this.name = 'AuthTokenError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
AuthTokenError.prototype = Object.create(Error.prototype);
function SilentMiddlewareBlockedError(message, type) {
this.name = 'SilentMiddlewareBlockedError';
this.message = message;
this.type = type;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
SilentMiddlewareBlockedError.prototype = Object.create(Error.prototype);
function InvalidActionError(message) {
this.name = 'InvalidActionError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
InvalidActionError.prototype = Object.create(Error.prototype);
function InvalidArgumentsError(message) {
this.name = 'InvalidArgumentsError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
InvalidArgumentsError.prototype = Object.create(Error.prototype);
function InvalidOptionsError(message) {
this.name = 'InvalidOptionsError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
InvalidOptionsError.prototype = Object.create(Error.prototype);
function InvalidMessageError(message) {
this.name = 'InvalidMessageError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
InvalidMessageError.prototype = Object.create(Error.prototype);
function SocketProtocolError(message, code) {
this.name = 'SocketProtocolError';
this.message = message;
this.code = code;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
SocketProtocolError.prototype = Object.create(Error.prototype);
function ServerProtocolError(message) {
this.name = 'ServerProtocolError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
ServerProtocolError.prototype = Object.create(Error.prototype);
function HTTPServerError(message) {
this.name = 'HTTPServerError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
HTTPServerError.prototype = Object.create(Error.prototype);
function ResourceLimitError(message) {
this.name = 'ResourceLimitError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
ResourceLimitError.prototype = Object.create(Error.prototype);
function TimeoutError(message) {
this.name = 'TimeoutError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
TimeoutError.prototype = Object.create(Error.prototype);
function BadConnectionError(message, type) {
this.name = 'BadConnectionError';
this.message = message;
this.type = type;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
BadConnectionError.prototype = Object.create(Error.prototype);
function BrokerError(message) {
this.name = 'BrokerError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
BrokerError.prototype = Object.create(Error.prototype);
function ProcessExitError(message, code) {
this.name = 'ProcessExitError';
this.message = message;
this.code = code;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
ProcessExitError.prototype = Object.create(Error.prototype);
function UnknownError(message) {
this.name = 'UnknownError';
this.message = message;
if (Error.captureStackTrace && !isStrict) {
Error.captureStackTrace(this, arguments.callee);
} else {
this.stack = (new Error()).stack;
}
}
UnknownError.prototype = Object.create(Error.prototype);
// Expose all error types.
module.exports = {
AuthTokenExpiredError: AuthTokenExpiredError,
AuthTokenInvalidError: AuthTokenInvalidError,
AuthTokenNotBeforeError: AuthTokenNotBeforeError,
AuthTokenError: AuthTokenError,
SilentMiddlewareBlockedError: SilentMiddlewareBlockedError,
InvalidActionError: InvalidActionError,
InvalidArgumentsError: InvalidArgumentsError,
InvalidOptionsError: InvalidOptionsError,
InvalidMessageError: InvalidMessageError,
SocketProtocolError: SocketProtocolError,
ServerProtocolError: ServerProtocolError,
HTTPServerError: HTTPServerError,
ResourceLimitError: ResourceLimitError,
TimeoutError: TimeoutError,
BadConnectionError: BadConnectionError,
BrokerError: BrokerError,
ProcessExitError: ProcessExitError,
UnknownError: UnknownError
};
module.exports.socketProtocolErrorStatuses = {
1001: 'Socket was disconnected',
1002: 'A WebSocket protocol error was encountered',
1003: 'Server terminated socket because it received invalid data',
1005: 'Socket closed without status code',
1006: 'Socket hung up',
1007: 'Message format was incorrect',
1008: 'Encountered a policy violation',
1009: 'Message was too big to process',
1010: 'Client ended the connection because the server did not comply with extension requirements',
1011: 'Server encountered an unexpected fatal condition',
4000: 'Server ping timed out',
4001: 'Client pong timed out',
4002: 'Server failed to sign auth token',
4003: 'Failed to complete handshake',
4004: 'Client failed to save auth token',
4005: 'Did not receive #handshake from client before timeout',
4006: 'Failed to bind socket to message broker',
4007: 'Client connection establishment timed out',
4008: 'Server rejected handshake from client'
};
module.exports.socketProtocolIgnoreStatuses = {
1000: 'Socket closed normally',
1001: 'Socket hung up'
};
// Properties related to error domains cannot be serialized.
var unserializableErrorProperties = {
domain: 1,
domainEmitter: 1,
domainThrown: 1
};
// Convert an error into a JSON-compatible type which can later be hydrated
// back to its *original* form.
module.exports.dehydrateError = function dehydrateError(error, includeStackTrace) {
var dehydratedError;
if (error && typeof error === 'object') {
dehydratedError = {
message: error.message
};
if (includeStackTrace) {
dehydratedError.stack = error.stack;
}
for (var i in error) {
if (!unserializableErrorProperties[i]) {
dehydratedError[i] = error[i];
}
}
} else if (typeof error === 'function') {
dehydratedError = '[function ' + (error.name || 'anonymous') + ']';
} else {
dehydratedError = error;
}
return decycle(dehydratedError);
};
// Convert a dehydrated error back to its *original* form.
module.exports.hydrateError = function hydrateError(error) {
var hydratedError = null;
if (error != null) {
if (typeof error === 'object') {
hydratedError = new Error(error.message);
for (var i in error) {
if (error.hasOwnProperty(i)) {
hydratedError[i] = error[i];
}
}
} else {
hydratedError = error;
}
}
return hydratedError;
};
module.exports.decycle = decycle;
+24
View File
@@ -0,0 +1,24 @@
{
"name": "sc-errors",
"version": "1.4.1",
"description": "Error types for use throughout SocketCluster",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/SocketCluster/sc-errors.git"
},
"keywords": [
"errors",
"socketcluster"
],
"author": "Jonathan Gros-Dubois <grosjona@yahoo.com.au>",
"license": "MIT",
"bugs": {
"url": "https://github.com/SocketCluster/sc-errors/issues"
},
"homepage": "https://github.com/SocketCluster/sc-errors",
"dependencies": {}
}