UNPKG

@fanoutio/subscriptions-transport-ws-over-http

Version:
1,073 lines (991 loc) 6.71 MB
var SubscriptionsTransportWsOverHttp = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/main.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./node_modules/@fanoutio/grip/build-esm/auth/Base.js": /*!************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/auth/Base.js ***! \************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // The authorization base class for building auth headers in conjunction // with HTTP requests used for publishing messages. var Base = /** @class */ (function () { function Base() { } return Base; }()); /* harmony default export */ __webpack_exports__["default"] = (Base); //# sourceMappingURL=Base.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/auth/Basic.js": /*!*************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/auth/Basic.js ***! \*************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Base */ "./node_modules/@fanoutio/grip/build-esm/auth/Base.js"); var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var Basic = /** @class */ (function (_super) { __extends(Basic, _super); function Basic(user, pass) { var _this = _super.call(this) || this; // Initialize with a username and password. _this.user = user; _this.pass = pass; return _this; } // Returns the auth header containing the username and password // in Basic auth format. Basic.prototype.buildHeader = function () { var data = this.user + ":" + this.pass; var dataBase64 = buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(data).toString('base64'); return "Basic " + dataBase64; }; return Basic; }(_Base__WEBPACK_IMPORTED_MODULE_1__["default"])); /* harmony default export */ __webpack_exports__["default"] = (Basic); //# sourceMappingURL=Basic.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/auth/Jwt.js": /*!***********************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/auth/Jwt.js ***! \***********************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var jsonwebtoken__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jsonwebtoken */ "./node_modules/jsonwebtoken/index.js"); /* harmony import */ var jsonwebtoken__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jsonwebtoken__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Base */ "./node_modules/@fanoutio/grip/build-esm/auth/Base.js"); var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); // JWT authentication class used for building auth headers containing // JSON web token information in either the form of a claim and // corresponding key, or the literal token itself. var Jwt = /** @class */ (function (_super) { __extends(Jwt, _super); function Jwt() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var _this = _super.call(this) || this; // Initialize with the specified claim and key. If only one parameter // was provided then treat it as the literal token. if (args.length === 1) { _this.token = args[0]; _this.claim = undefined; _this.key = undefined; } else { _this.token = undefined; _this.claim = args[0]; _this.key = args[1] instanceof buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"] ? args[1] : buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(String(args[1]), 'utf8'); } return _this; } // Returns the auth header containing the JWT token in Bearer format. Jwt.prototype.buildHeader = function () { var token; if (this.token != null) { token = this.token; } else { token = jsonwebtoken__WEBPACK_IMPORTED_MODULE_1__["sign"](this.claim, this.key, { expiresIn: '10m' }); } return "Bearer " + token; }; return Jwt; }(_Base__WEBPACK_IMPORTED_MODULE_2__["default"])); /* harmony default export */ __webpack_exports__["default"] = (Jwt); //# sourceMappingURL=Jwt.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/auth/index.js": /*!*************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/auth/index.js ***! \*************************************************************/ /*! exports provided: Base, Basic, Jwt */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Base */ "./node_modules/@fanoutio/grip/build-esm/auth/Base.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Base", function() { return _Base__WEBPACK_IMPORTED_MODULE_0__["default"]; }); /* harmony import */ var _Basic__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Basic */ "./node_modules/@fanoutio/grip/build-esm/auth/Basic.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Basic", function() { return _Basic__WEBPACK_IMPORTED_MODULE_1__["default"]; }); /* harmony import */ var _Jwt__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Jwt */ "./node_modules/@fanoutio/grip/build-esm/auth/Jwt.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Jwt", function() { return _Jwt__WEBPACK_IMPORTED_MODULE_2__["default"]; }); //# sourceMappingURL=index.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/Channel.js": /*!***************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/Channel.js ***! \***************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // The Channel class is used to represent a channel in a GRIP proxy and // tracks the previous ID of the last message. var Channel = /** @class */ (function () { function Channel(name, prevId) { if (prevId === void 0) { prevId = null; } this.name = name; this.prevId = prevId; } // Export this channel instance into a dictionary containing the // name and previous ID value. Channel.prototype.export = function () { var obj = { name: this.name }; if (this.prevId != null) { obj.prevId = this.prevId; } return obj; }; return Channel; }()); /* harmony default export */ __webpack_exports__["default"] = (Channel); //# sourceMappingURL=Channel.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/Format.js": /*!**************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/Format.js ***! \**************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // The Format class is provided as a base class for all publishing // formats that are included in the Item class. Examples of format // implementations include JsonObjectFormat and HttpStreamFormat. // In pure TypeScript this would not be needed (implementations would // only need to implement IFormat), but since this needs to be consumable // from JavaScript, we are exporting this class. var Format = /** @class */ (function () { function Format() { } return Format; }()); /* harmony default export */ __webpack_exports__["default"] = (Format); //# sourceMappingURL=Format.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/GripInstruct.js": /*!********************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/GripInstruct.js ***! \********************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utilities_grip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utilities/grip */ "./node_modules/@fanoutio/grip/build-esm/utilities/grip.js"); /* harmony import */ var _utilities_http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utilities/http */ "./node_modules/@fanoutio/grip/build-esm/utilities/http.js"); var GripInstruct = /** @class */ (function () { function GripInstruct(channels) { this.channels = []; this.timeout = 0; this.keepAliveTimeout = 0; this.nextLinkTimeout = 0; if (channels != null) { this.addChannel(channels); } } GripInstruct.prototype.addChannel = function (channels) { var _a; (_a = this.channels).push.apply(_a, Object(_utilities_grip__WEBPACK_IMPORTED_MODULE_0__["parseChannels"])(channels)); }; GripInstruct.prototype.setStatus = function (status) { this.status = status; }; GripInstruct.prototype.setHoldLongPoll = function (timeout) { this.hold = 'response'; if (timeout != null) { this.timeout = Math.floor(timeout); } }; GripInstruct.prototype.setHoldStream = function () { this.hold = 'stream'; }; GripInstruct.prototype.setKeepAlive = function (data, timeout) { this.keepAlive = data; this.keepAliveTimeout = timeout; }; GripInstruct.prototype.setNextLink = function (uri, timeout) { if (timeout === void 0) { timeout = 0; } this.nextLink = uri; this.nextLinkTimeout = timeout; }; GripInstruct.prototype.toHeaders = function (additionalHeaders) { var headers = {}; headers['Grip-Channel'] = Object(_utilities_grip__WEBPACK_IMPORTED_MODULE_0__["createGripChannelHeader"])(this.channels); if (this.status != null) { headers['Grip-Status'] = "" + this.status; // Convert to string } if (this.hold != null) { headers['Grip-Hold'] = this.hold; if (this.timeout > 0) { headers['Grip-Timeout'] = "" + this.timeout; // Convert to string } if (this.keepAlive != null) { headers['Grip-Keep-Alive'] = Object(_utilities_http__WEBPACK_IMPORTED_MODULE_1__["createKeepAliveHeader"])(this.keepAlive, this.keepAliveTimeout); } if (this.meta != null && Object.entries(this.meta).length > 0) { headers['Grip-Set-Meta'] = Object(_utilities_http__WEBPACK_IMPORTED_MODULE_1__["createMetaHeader"])(this.meta); } } if (this.nextLink != null) { headers['Grip-Link'] = Object(_utilities_http__WEBPACK_IMPORTED_MODULE_1__["createNextLinkHeader"])(this.nextLink, this.nextLinkTimeout); } Object.assign(headers, additionalHeaders); return headers; }; return GripInstruct; }()); /* harmony default export */ __webpack_exports__["default"] = (GripInstruct); //# sourceMappingURL=GripInstruct.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/Item.js": /*!************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/Item.js ***! \************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // The Item class is a container used to contain one or more format // implementation instances where each implementation instance is of a // different type of format. An Item instance may not contain multiple // implementations of the same type of format. An Item instance is then // serialized into a hash that is used for publishing to clients. var Item = /** @class */ (function () { function Item(formats, id, prevId) { // The initialize method can accept either a single Format implementation // instance or an array of Format implementation instances. Optionally // specify an ID and/or previous ID to be sent as part of the message // published to the client. formats = Array.isArray(formats) ? formats : [formats]; this.formats = formats; if (arguments.length >= 3) { this.prevId = prevId; } if (arguments.length >= 2) { this.id = id; } } // The export method serializes all of the formats, ID, and previous ID // into a hash that is used for publishing to clients. If more than one // instance of the same type of Format implementation was specified then // an error will be raised. Item.prototype.export = function () { var obj = { formats: {}, }; if (this.id != null) { obj.id = this.id; } if (this.prevId != null) { obj['prev-id'] = this.prevId; } var alreadyUsedFormatNames = new Set(); for (var _i = 0, _a = this.formats; _i < _a.length; _i++) { var format = _a[_i]; var name_1 = format.name(); if (alreadyUsedFormatNames.has(name_1)) { throw new Error("More than one instance of " + name_1 + " specified"); } alreadyUsedFormatNames.add(name_1); obj.formats[name_1] = format.export(); } return obj; }; return Item; }()); /* harmony default export */ __webpack_exports__["default"] = (Item); //# sourceMappingURL=Item.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/PublishException.js": /*!************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/PublishException.js ***! \************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); var PublishException = /** @class */ (function () { function PublishException(message, context) { this.message = message; this.context = context; } return PublishException; }()); /* harmony default export */ __webpack_exports__["default"] = (PublishException); //# sourceMappingURL=PublishException.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/Response.js": /*!****************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/Response.js ***! \****************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__); // The Response class is used to represent a set of HTTP response data. // Populated instances of this class are serialized to JSON and passed // to the GRIP proxy in the body. The GRIP proxy then parses the message // and deserialized the JSON into an HTTP response that is passed back // to the client. var Response = /** @class */ (function () { function Response() { var _a, _b, _c, _d, _e, _f, _g, _h, _j; var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var code, reason, headers, body; // Initialize with the message code, reason, headers, and body to send // to the client when the message is published. If only one parameter // is passed then treat it as a dictionary object containing all of // the data in the form of key/value pairs. if (args.length === 1) { (_a = args[0], _b = _a.code, code = _b === void 0 ? null : _b, _c = _a.reason, reason = _c === void 0 ? null : _c, _d = _a.headers, headers = _d === void 0 ? null : _d, _e = _a.body, body = _e === void 0 ? null : _e); } else { _f = args[0], code = _f === void 0 ? null : _f, _g = args[1], reason = _g === void 0 ? null : _g, _h = args[2], headers = _h === void 0 ? null : _h, _j = args[3], body = _j === void 0 ? null : _j; } this.code = code; this.reason = reason; this.headers = headers; this.body = body; } // Export this Response instance into a dictionary containing all // of the non-null data. If the body is set to a buffer then export // it as 'body-bin' (as opposed to 'body') and encode it as base64. Response.prototype.export = function () { var obj = {}; if (this.code != null) { obj.code = this.code; } if (this.reason != null) { obj.reason = this.reason; } if (this.headers != null) { obj.headers = this.headers; } if (this.body != null) { if (buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].isBuffer(this.body)) { obj['body-bin'] = this.body.toString('base64'); } else { obj['body'] = this.body.toString(); } } return obj; }; return Response; }()); /* harmony default export */ __webpack_exports__["default"] = (Response); //# sourceMappingURL=Response.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/http/HttpResponseFormat.js": /*!*******************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/http/HttpResponseFormat.js ***! \*******************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Response__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Response */ "./node_modules/@fanoutio/grip/build-esm/data/Response.js"); var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); // The HttpResponseFormat class is the format used to publish messages to // HTTP response clients connected to a GRIP proxy. var HttpResponseFormat = /** @class */ (function (_super) { __extends(HttpResponseFormat, _super); function HttpResponseFormat() { return _super !== null && _super.apply(this, arguments) || this; } // The name used when publishing this format. HttpResponseFormat.prototype.name = function () { return 'http-response'; }; return HttpResponseFormat; }(_Response__WEBPACK_IMPORTED_MODULE_0__["default"])); /* harmony default export */ __webpack_exports__["default"] = (HttpResponseFormat); //# sourceMappingURL=HttpResponseFormat.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/http/HttpStreamFormat.js": /*!*****************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/http/HttpStreamFormat.js ***! \*****************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__); // The HttpStreamFormat class is the format used to publish messages to // HTTP stream clients connected to a GRIP proxy. var HttpStreamFormat = /** @class */ (function () { function HttpStreamFormat(content, close) { if (content === void 0) { content = null; } if (close === void 0) { close = false; } // Initialize with either the message content or a boolean indicating that // the streaming connection should be closed. If neither the content nor // the boolean flag is set then an error will be thrown. if (content == null && !close) { throw new Error('HttpStreamFormat requires content.'); } this.content = content; this.close = close; } // The name used when publishing this format. HttpStreamFormat.prototype.name = function () { return 'http-stream'; }; // Exports the message in the required format depending on whether the // message content is binary or not, or whether the connection should // be closed. HttpStreamFormat.prototype.export = function () { var obj = {}; if (this.close) { obj['action'] = 'close'; obj['content'] = ''; } else { if (buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].isBuffer(this.content)) { obj['content-bin'] = this.content.toString('base64'); } else if (this.content != null) { obj['content'] = this.content.toString(); } } return obj; }; return HttpStreamFormat; }()); /* harmony default export */ __webpack_exports__["default"] = (HttpStreamFormat); //# sourceMappingURL=HttpStreamFormat.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/websocket/ConnectionIdMissingException.js": /*!**********************************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/websocket/ConnectionIdMissingException.js ***! \**********************************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _WebSocketException__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./WebSocketException */ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketException.js"); var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var ConnectionIdMissingException = /** @class */ (function (_super) { __extends(ConnectionIdMissingException, _super); function ConnectionIdMissingException() { return _super !== null && _super.apply(this, arguments) || this; } return ConnectionIdMissingException; }(_WebSocketException__WEBPACK_IMPORTED_MODULE_0__["default"])); /* harmony default export */ __webpack_exports__["default"] = (ConnectionIdMissingException); //# sourceMappingURL=ConnectionIdMissingException.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketContext.js": /*!**********************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketContext.js ***! \**********************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var jspack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! jspack */ "./node_modules/jspack/jspack.js"); /* harmony import */ var jspack__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(jspack__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _utilities_webSocketEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utilities/webSocketEvents */ "./node_modules/@fanoutio/grip/build-esm/utilities/webSocketEvents.js"); /* harmony import */ var _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./WebSocketEvent */ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketEvent.js"); /* harmony import */ var _utilities_string__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utilities/string */ "./node_modules/@fanoutio/grip/build-esm/utilities/string.js"); /* harmony import */ var _utilities_debug__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utilities/debug */ "./node_modules/@fanoutio/grip/build-esm/utilities/debug.js"); var __spreadArrays = (undefined && undefined.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; /// <reference path="../../../types/jspack.d.ts" /> var WebSocketContext = /** @class */ (function () { function WebSocketContext(id, meta, inEvents, optionsParam) { if (optionsParam === void 0) { optionsParam = ''; } var _a, _b; this.readIndex = 0; this.accepted = false; this.closeCode = null; this.closed = false; this.outCloseCode = null; this.outEvents = []; this.id = id; this.meta = JSON.parse(JSON.stringify(meta)); this.origMeta = meta; this.inEvents = inEvents; var options = Object(_utilities_string__WEBPACK_IMPORTED_MODULE_4__["isString"])(optionsParam) ? { prefix: optionsParam, } : optionsParam; this.prefix = (_a = options.prefix) !== null && _a !== void 0 ? _a : ''; this.subprotocols = (_b = options.subprotocols) !== null && _b !== void 0 ? _b : []; this.acceptedSubprotocol = null; } WebSocketContext.prototype.isOpening = function () { return Array.isArray(this.inEvents) && this.inEvents.length > 0 && this.inEvents[0].type === 'OPEN'; }; WebSocketContext.prototype.accept = function () { this.accepted = true; }; WebSocketContext.prototype.close = function (code) { if (code === void 0) { code = 0; } this.closed = true; this.outCloseCode = code; }; WebSocketContext.prototype.canRecv = function () { for (var n = this.readIndex; n < this.inEvents.length; n++) { if (['TEXT', 'BINARY', 'CLOSE', 'DISCONNECT'].indexOf(this.inEvents[n].type) > -1) { return true; } } return false; }; WebSocketContext.prototype.disconnect = function () { this.outEvents.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('DISCONNECT')); }; WebSocketContext.prototype.recvRaw = function () { var e = null; while (e == null && this.readIndex < this.inEvents.length) { if (['TEXT', 'BINARY', 'CLOSE', 'DISCONNECT'].indexOf(this.inEvents[this.readIndex].type) > -1) { e = this.inEvents[this.readIndex]; } else if (this.inEvents[this.readIndex].type === 'PING') { this.outEvents.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('PONG')); } this.readIndex += 1; } if (e == null) { throw new Error('Read from empty buffer.'); } var type = e.type; if (type === 'TEXT') { return e.content != null ? e.content.toString() : ''; } if (type === 'BINARY') { return e.content != null ? e.content : buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].alloc(0); } if (type === 'CLOSE') { var content = e.content; if (Array.isArray(content) && content.length === 2) { this.closeCode = jspack__WEBPACK_IMPORTED_MODULE_1__["jspack"].Unpack('>H', __spreadArrays(content))[0]; } return null; } else { throw new Error('Client disconnected unexpectedly.'); } }; WebSocketContext.prototype.recv = function () { var result = this.recvRaw(); if (result == null) { return null; } else { return result.toString(); } }; WebSocketContext.prototype.send = function (message) { this.outEvents.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('TEXT', buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].concat([buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from('m:'), message instanceof buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"] ? message : buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(message)]))); }; WebSocketContext.prototype.sendBinary = function (message) { this.outEvents.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('BINARY', buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].concat([buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from('m:'), message instanceof buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"] ? message : buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(message)]))); }; WebSocketContext.prototype.sendControl = function (message) { this.outEvents.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('TEXT', buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].concat([buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from('c:'), message instanceof buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"] ? message : buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(message)]))); }; WebSocketContext.prototype.subscribe = function (channel) { this.sendControl(Object(_utilities_webSocketEvents__WEBPACK_IMPORTED_MODULE_2__["createWebSocketControlMessage"])('subscribe', { channel: this.prefix + channel })); }; WebSocketContext.prototype.unsubscribe = function (channel) { this.sendControl(Object(_utilities_webSocketEvents__WEBPACK_IMPORTED_MODULE_2__["createWebSocketControlMessage"])('unsubscribe', { channel: this.prefix + channel })); }; WebSocketContext.prototype.detach = function () { this.sendControl(Object(_utilities_webSocketEvents__WEBPACK_IMPORTED_MODULE_2__["createWebSocketControlMessage"])('detach')); }; WebSocketContext.prototype.getReqSubprotocols = function () { return this.subprotocols; }; WebSocketContext.prototype.acceptSubprotocol = function (subprotocol) { if (subprotocol != null && !this.subprotocols.includes(subprotocol)) { Object(_utilities_debug__WEBPACK_IMPORTED_MODULE_5__["default"])('WebSocketContext.acceptSubprotocol: Cannot accept subprotocol ' + subprotocol + '.'); Object(_utilities_debug__WEBPACK_IMPORTED_MODULE_5__["default"])('WebSocketContext.acceptSubprotocol: Request subprotocol list: ' + this.subprotocols.join(',') + "."); return false; } this.acceptedSubprotocol = subprotocol; return true; }; WebSocketContext.prototype.getOutgoingEvents = function () { var events = []; if (this.accepted) { events.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('OPEN')); } for (var _i = 0, _a = this.outEvents; _i < _a.length; _i++) { var event_1 = _a[_i]; events.push(event_1); } if (this.closed) { var octets = jspack__WEBPACK_IMPORTED_MODULE_1__["jspack"].Pack('>H', [this.outCloseCode]); if (octets !== false) { events.push(new _WebSocketEvent__WEBPACK_IMPORTED_MODULE_3__["default"]('CLOSE', buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(octets))); } } return events; }; WebSocketContext.prototype.toHeaders = function () { var _this = this; // Find all keys of wsContext.origMeta that don't have the same key // in wsContext.meta var metaToRemove = Object.keys(this.origMeta).filter(function (k) { return Object.keys(_this.meta).every(function (nk) { return nk.toLowerCase() !== k; }); }); // Find all items in wsContext.meta whose keys and values don't match // any in wsContext.origMeta var metaToSet = Object.entries(this.meta).reduce(function (acc, _a) { var nk = _a[0], nv = _a[1]; var lname = nk.toLowerCase(); if (Object.entries(_this.origMeta).every(function (_a) { var k = _a[0], v = _a[1]; return lname !== k || nv !== v; })) { acc[lname] = nv; } return acc; }, {}); var headers = { 'Content-Type': 'application/websocket-events', }; if (this.accepted) { headers['Sec-WebSocket-Extensions'] = 'grip'; } if (this.acceptedSubprotocol != null) { headers['Sec-WebSocket-Protocol'] = this.acceptedSubprotocol; } for (var _i = 0, metaToRemove_1 = metaToRemove; _i < metaToRemove_1.length; _i++) { var k = metaToRemove_1[_i]; headers['Set-Meta-' + k] = ''; } for (var _a = 0, _b = Object.entries(metaToSet); _a < _b.length; _a++) { var _c = _b[_a], k = _c[0], v = _c[1]; headers['Set-Meta-' + k] = String(v); } return headers; }; return WebSocketContext; }()); /* harmony default export */ __webpack_exports__["default"] = (WebSocketContext); //# sourceMappingURL=WebSocketContext.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketDecodeEventException.js": /*!***********************************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketDecodeEventException.js ***! \***********************************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _WebSocketException__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./WebSocketException */ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketException.js"); var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var WebSocketDecodeEventException = /** @class */ (function (_super) { __extends(WebSocketDecodeEventException, _super); function WebSocketDecodeEventException() { return _super !== null && _super.apply(this, arguments) || this; } return WebSocketDecodeEventException; }(_WebSocketException__WEBPACK_IMPORTED_MODULE_0__["default"])); /* harmony default export */ __webpack_exports__["default"] = (WebSocketDecodeEventException); //# sourceMappingURL=WebSocketDecodeEventException.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketEvent.js": /*!********************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketEvent.js ***! \********************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); // The WebSocketEvent class represents WebSocket event information that is // used with the GRIP WebSocket-over-HTTP protocol. It includes information // about the type of event as well as an optional content field. var WebSocketEvent = /** @class */ (function () { function WebSocketEvent(type, content) { if (content === void 0) { content = null; } // Initialize with a specified event type and optional content information. this.type = type; this.content = content; } // Get the event type. WebSocketEvent.prototype.getType = function () { return this.type; }; // Get the event content. WebSocketEvent.prototype.getContent = function () { return this.content; }; return WebSocketEvent; }()); /* harmony default export */ __webpack_exports__["default"] = (WebSocketEvent); //# sourceMappingURL=WebSocketEvent.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketException.js": /*!************************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketException.js ***! \************************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); var __extends = (undefined && undefined.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var WebSocketException = /** @class */ (function (_super) { __extends(WebSocketException, _super); function WebSocketException() { return _super !== null && _super.apply(this, arguments) || this; } return WebSocketException; }(Error)); /* harmony default export */ __webpack_exports__["default"] = (WebSocketException); //# sourceMappingURL=WebSocketException.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketMessageFormat.js": /*!****************************************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/data/websocket/WebSocketMessageFormat.js ***! \****************************************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "./node_modules/buffer/index.js"); /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__); // The WebSocketMessageFormat class is the format used to publish data to // WebSocket clients connected to GRIP proxies. var WebSocketMessageFormat = /** @class */ (function () { function WebSocketMessageFormat(content, close, code) { if (content === void 0) { content = null; } if (close === void 0) { close = false; } // Initialize with either the message content or a boolean indicating that // the streaming connection should be closed. If neither the content nor // the boolean flag is set then an error will be thrown. if (content == null && !close) { throw new Error('WebSocketMessageFormat requires content.'); } this.content = content; this.close = close; this.code = code; } // The name used when publishing this format. WebSocketMessageFormat.prototype.name = function () { return 'ws-message'; }; // Exports the message in the required format depending on whether the // message content is a buffer or not, or whether the connection should // be closed. WebSocketMessageFormat.prototype.export = function () { var obj = {}; if (this.close) { obj['action'] = 'close'; if (this.code != null) { obj['code'] = this.code; } } else { if (buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].isBuffer(this.content)) { obj['content-bin'] = this.content.toString('base64'); } else if (this.content != null) { obj['content'] = this.content.toString(); } } return obj; }; return WebSocketMessageFormat; }()); /* harmony default export */ __webpack_exports__["default"] = (WebSocketMessageFormat); //# sourceMappingURL=WebSocketMessageFormat.js.map /***/ }), /***/ "./node_modules/@fanoutio/grip/build-esm/engine/Publisher.js": /*!*******************************************************************!*\ !*** ./node_modules/@fanoutio/grip/build-esm/engine/Publisher.js ***! \*******************************************************************/ /*! exports provided: default */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _data_Item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../data/Item */ "./node_modules/@fanoutio/grip/build-esm/data/Item.js"); /* harmony import */ var _data_http_HttpStreamFormat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../data/http/HttpStreamFormat */ "./node_modules/@fanoutio/grip/build-esm/data/http/HttpStreamFormat.js"); /* harmony import */ var _data_http_HttpResponseFormat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../data/http/HttpResponseFormat */ "./node_modules/@fanoutio/grip/build-esm/data/http/HttpResponseFormat.js"); /* harmony import */ var _PublisherClient__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PublisherClient */ "./node_modules/@fanoutio/grip/build-esm/engine/PublisherClient.js"); /* harmony import */ var _utilities_grip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utilities/grip */ "./node_modules/@fanoutio/grip/build-esm/utilities/grip.js"); var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value);