diff --git a/dist/certstream.js b/dist/certstream.js index 6e0d7d0..bb6d3c9 100644 --- a/dist/certstream.js +++ b/dist/certstream.js @@ -86,9 +86,11 @@ return /******/ (function(modules) { // webpackBootstrap value: function connect() { var _this = this; - console.log("Connecting..."); + var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "wss://certstream.calidog.io/"; - this.ws = new _reconnectingwebsocket2.default("wss://certstream.calidog.io/"); + console.log("Connecting to " + url + "..."); + + this.ws = new _reconnectingwebsocket2.default(url); console.log("Created ws -> ", this.ws); diff --git a/dist/certstream.js.map b/dist/certstream.js.map index 4f9f3b8..417f0ee 100644 --- a/dist/certstream.js.map +++ b/dist/certstream.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 8f4509fcce0e7bf2616b","webpack:///./src/browser.js","webpack:///./~/reconnectingwebsocket/reconnecting-websocket.js"],"names":["CertStreamClient","callback","skipHeartbeats","context","console","log","ws","onmessage","message","parsedMessage","JSON","parse","data","message_type","onopen","open"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;ACtCA;;;;;;;;KAEqBA,gB;AACjB,+BAAYC,QAAZ,EAA8C;AAAA,aAAxBC,cAAwB,uEAAP,KAAO;;AAAA;;AAC1C,cAAKC,OAAL,GAAe,EAAf;AACA,cAAKF,QAAL,GAAgBA,QAAhB;AACA,cAAKC,cAAL,GAAsBA,cAAtB;AACH;;;;mCAEQ;AAAA;;AACLE,qBAAQC,GAAR,CAAY,eAAZ;;AAEA,kBAAKC,EAAL,GAAU,oCAA0B,8BAA1B,CAAV;;AAEAF,qBAAQC,GAAR,CAAY,gBAAZ,EAA8B,KAAKC,EAAnC;;AAEA,kBAAKA,EAAL,CAAQC,SAAR,GAAoB,UAACC,OAAD,EAAa;AAC7BJ,yBAAQC,GAAR,CAAY,mBAAZ;AACA,qBAAII,gBAAgBC,KAAKC,KAAL,CAAWH,QAAQI,IAAnB,CAApB;;AAEA,qBAAIH,cAAcI,YAAd,KAA+B,WAA/B,IAA8C,MAAKX,cAAvD,EAAuE;AACnE;AACH;;AAED,uBAAKD,QAAL,CAAcO,OAAd,EAAuB,MAAKL,OAA5B;AACH,cATD;;AAWA,kBAAKG,EAAL,CAAQQ,MAAR,GAAiB,YAAM;AACnBV,yBAAQC,GAAR,CAAY,+DAAZ;AACH,cAFD;;AAIA,kBAAKC,EAAL,CAAQS,IAAR;AACH;;;;;;mBA9BgBf,gB;AA+BpB,E;;;;;;ACjCD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAsD,uCAAuC;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;AACA,EAAC;;AAED;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,wBAAuB,cAAc;;AAErC;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iFAAgF;AAChF;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,qEAAoE,oBAAoB,EAAE;AAC1F,qEAAoE,qBAAqB,EAAE;AAC3F,qEAAoE,0BAA0B,EAAE;AAChG,qEAAoE,uBAAuB,EAAE;AAC7F,qEAAoE,qBAAqB,EAAE;;AAE3F;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,EAAC","file":"certstream.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CertStream\"] = factory();\n\telse\n\t\troot[\"CertStream\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 8f4509fcce0e7bf2616b","import ReconnectingWebsocket from \"reconnectingwebsocket\"\n\nexport default class CertStreamClient{\n constructor(callback, skipHeartbeats = false) {\n this.context = {};\n this.callback = callback;\n this.skipHeartbeats = skipHeartbeats;\n }\n\n connect(){\n console.log(\"Connecting...\");\n\n this.ws = new ReconnectingWebsocket(\"wss://certstream.calidog.io/\");\n\n console.log(\"Created ws -> \", this.ws);\n\n this.ws.onmessage = (message) => {\n console.log(\"onmessage called!\");\n let parsedMessage = JSON.parse(message.data);\n\n if (parsedMessage.message_type === \"heartbeat\" && this.skipHeartbeats) {\n return\n }\n\n this.callback(message, this.context)\n };\n\n this.ws.onopen = () => {\n console.log(\"Connection established to certstream! Waiting for messages...\");\n }\n\n this.ws.open();\n }\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/browser.js","// MIT License:\n//\n// Copyright (c) 2010-2012, Joe Walnes\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/**\n * This behaves like a WebSocket in every way, except if it fails to connect,\n * or it gets disconnected, it will repeatedly poll until it successfully connects\n * again.\n *\n * It is API compatible, so when you have:\n * ws = new WebSocket('ws://....');\n * you can replace with:\n * ws = new ReconnectingWebSocket('ws://....');\n *\n * The event stream will typically look like:\n * onconnecting\n * onopen\n * onmessage\n * onmessage\n * onclose // lost connection\n * onconnecting\n * onopen // sometime later...\n * onmessage\n * onmessage\n * etc...\n *\n * It is API compatible with the standard WebSocket API, apart from the following members:\n *\n * - `bufferedAmount`\n * - `extensions`\n * - `binaryType`\n *\n * Latest version: https://github.com/joewalnes/reconnecting-websocket/\n * - Joe Walnes\n *\n * Syntax\n * ======\n * var socket = new ReconnectingWebSocket(url, protocols, options);\n *\n * Parameters\n * ==========\n * url - The url you are connecting to.\n * protocols - Optional string or array of protocols.\n * options - See below\n *\n * Options\n * =======\n * Options can either be passed upon instantiation or set after instantiation:\n *\n * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });\n *\n * or\n *\n * var socket = new ReconnectingWebSocket(url);\n * socket.debug = true;\n * socket.reconnectInterval = 4000;\n *\n * debug\n * - Whether this instance should log debug messages. Accepts true or false. Default: false.\n *\n * automaticOpen\n * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n *\n * reconnectInterval\n * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.\n *\n * maxReconnectInterval\n * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.\n *\n * reconnectDecay\n * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.\n *\n * timeoutInterval\n * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.\n *\n */\n(function (global, factory) {\n if (typeof define === 'function' && define.amd) {\n define([], factory);\n } else if (typeof module !== 'undefined' && module.exports){\n module.exports = factory();\n } else {\n global.ReconnectingWebSocket = factory();\n }\n})(this, function () {\n\n if (!('WebSocket' in window)) {\n return;\n }\n\n function ReconnectingWebSocket(url, protocols, options) {\n\n // Default settings\n var settings = {\n\n /** Whether this instance should log debug messages. */\n debug: false,\n\n /** Whether or not the websocket should attempt to connect immediately upon instantiation. */\n automaticOpen: true,\n\n /** The number of milliseconds to delay before attempting to reconnect. */\n reconnectInterval: 1000,\n /** The maximum number of milliseconds to delay a reconnection attempt. */\n maxReconnectInterval: 30000,\n /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */\n reconnectDecay: 1.5,\n\n /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */\n timeoutInterval: 2000,\n\n /** The maximum number of reconnection attempts to make. Unlimited if null. */\n maxReconnectAttempts: null\n }\n if (!options) { options = {}; }\n\n // Overwrite and define settings with options if they exist.\n for (var key in settings) {\n if (typeof options[key] !== 'undefined') {\n this[key] = options[key];\n } else {\n this[key] = settings[key];\n }\n }\n\n // These should be treated as read-only properties\n\n /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */\n this.url = url;\n\n /** The number of attempted reconnects since starting, or the last successful connection. Read only. */\n this.reconnectAttempts = 0;\n\n /**\n * The current state of the connection.\n * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED\n * Read only.\n */\n this.readyState = WebSocket.CONNECTING;\n\n /**\n * A string indicating the name of the sub-protocol the server selected; this will be one of\n * the strings specified in the protocols parameter when creating the WebSocket object.\n * Read only.\n */\n this.protocol = null;\n\n // Private state variables\n\n var self = this;\n var ws;\n var forcedClose = false;\n var timedOut = false;\n var eventTarget = document.createElement('div');\n\n // Wire up \"on*\" properties as event handlers\n\n eventTarget.addEventListener('open', function(event) { self.onopen(event); });\n eventTarget.addEventListener('close', function(event) { self.onclose(event); });\n eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });\n eventTarget.addEventListener('message', function(event) { self.onmessage(event); });\n eventTarget.addEventListener('error', function(event) { self.onerror(event); });\n\n // Expose the API required by EventTarget\n\n this.addEventListener = eventTarget.addEventListener.bind(eventTarget);\n this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);\n this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);\n\n /**\n * This function generates an event that is compatible with standard\n * compliant browsers and IE9 - IE11\n *\n * This will prevent the error:\n * Object doesn't support this action\n *\n * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563\n * @param s String The name that the event should use\n * @param args Object an optional object that the event will use\n */\n function generateEvent(s, args) {\n \tvar evt = document.createEvent(\"CustomEvent\");\n \tevt.initCustomEvent(s, false, false, args);\n \treturn evt;\n };\n\n this.open = function (reconnectAttempt) {\n ws = new WebSocket(self.url, protocols || []);\n\n if (reconnectAttempt) {\n if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {\n return;\n }\n } else {\n eventTarget.dispatchEvent(generateEvent('connecting'));\n this.reconnectAttempts = 0;\n }\n\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);\n }\n\n var localWs = ws;\n var timeout = setTimeout(function() {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);\n }\n timedOut = true;\n localWs.close();\n timedOut = false;\n }, self.timeoutInterval);\n\n ws.onopen = function(event) {\n clearTimeout(timeout);\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onopen', self.url);\n }\n self.protocol = ws.protocol;\n self.readyState = WebSocket.OPEN;\n self.reconnectAttempts = 0;\n var e = generateEvent('open');\n e.isReconnect = reconnectAttempt;\n reconnectAttempt = false;\n eventTarget.dispatchEvent(e);\n };\n\n ws.onclose = function(event) {\n clearTimeout(timeout);\n ws = null;\n if (forcedClose) {\n self.readyState = WebSocket.CLOSED;\n eventTarget.dispatchEvent(generateEvent('close'));\n } else {\n self.readyState = WebSocket.CONNECTING;\n var e = generateEvent('connecting');\n e.code = event.code;\n e.reason = event.reason;\n e.wasClean = event.wasClean;\n eventTarget.dispatchEvent(e);\n if (!reconnectAttempt && !timedOut) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onclose', self.url);\n }\n eventTarget.dispatchEvent(generateEvent('close'));\n }\n\n var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);\n setTimeout(function() {\n self.reconnectAttempts++;\n self.open(true);\n }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);\n }\n };\n ws.onmessage = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);\n }\n var e = generateEvent('message');\n e.data = event.data;\n eventTarget.dispatchEvent(e);\n };\n ws.onerror = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onerror', self.url, event);\n }\n eventTarget.dispatchEvent(generateEvent('error'));\n };\n }\n\n // Whether or not to create a websocket upon instantiation\n if (this.automaticOpen == true) {\n this.open(false);\n }\n\n /**\n * Transmits data to the server over the WebSocket connection.\n *\n * @param data a text string, ArrayBuffer or Blob to send to the server.\n */\n this.send = function(data) {\n if (ws) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'send', self.url, data);\n }\n return ws.send(data);\n } else {\n throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';\n }\n };\n\n /**\n * Closes the WebSocket connection or connection attempt, if any.\n * If the connection is already CLOSED, this method does nothing.\n */\n this.close = function(code, reason) {\n // Default CLOSE_NORMAL code\n if (typeof code == 'undefined') {\n code = 1000;\n }\n forcedClose = true;\n if (ws) {\n ws.close(code, reason);\n }\n };\n\n /**\n * Additional public API method to refresh the connection if still open (close, re-open).\n * For example, if the app suspects bad data / missed heart beats, it can try to refresh.\n */\n this.refresh = function() {\n if (ws) {\n ws.close();\n }\n };\n }\n\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n * this indicates that the connection is ready to send and receive data.\n */\n ReconnectingWebSocket.prototype.onopen = function(event) {};\n /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */\n ReconnectingWebSocket.prototype.onclose = function(event) {};\n /** An event listener to be called when a connection begins being attempted. */\n ReconnectingWebSocket.prototype.onconnecting = function(event) {};\n /** An event listener to be called when a message is received from the server. */\n ReconnectingWebSocket.prototype.onmessage = function(event) {};\n /** An event listener to be called when an error occurs. */\n ReconnectingWebSocket.prototype.onerror = function(event) {};\n\n /**\n * Whether all instances of ReconnectingWebSocket should log debug messages.\n * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.\n */\n ReconnectingWebSocket.debugAll = false;\n\n ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;\n ReconnectingWebSocket.OPEN = WebSocket.OPEN;\n ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;\n ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;\n\n return ReconnectingWebSocket;\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/reconnectingwebsocket/reconnecting-websocket.js\n// module id = 1\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 1ebd651b81469407348b","webpack:///./src/browser.js","webpack:///./~/reconnectingwebsocket/reconnecting-websocket.js"],"names":["CertStreamClient","callback","skipHeartbeats","context","url","console","log","ws","onmessage","message","parsedMessage","JSON","parse","data","message_type","onopen","open"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;ACtCA;;;;;;;;KAEqBA,gB;AACjB,+BAAYC,QAAZ,EAA8C;AAAA,aAAxBC,cAAwB,uEAAP,KAAO;;AAAA;;AAC1C,cAAKC,OAAL,GAAe,EAAf;AACA,cAAKF,QAAL,GAAgBA,QAAhB;AACA,cAAKC,cAAL,GAAsBA,cAAtB;AACH;;;;mCAE0C;AAAA;;AAAA,iBAAnCE,GAAmC,uEAA/B,8BAA+B;;AACvCC,qBAAQC,GAAR,oBAA6BF,GAA7B;;AAEA,kBAAKG,EAAL,GAAU,oCAA0BH,GAA1B,CAAV;;AAEAC,qBAAQC,GAAR,CAAY,gBAAZ,EAA8B,KAAKC,EAAnC;;AAEA,kBAAKA,EAAL,CAAQC,SAAR,GAAoB,UAACC,OAAD,EAAa;AAC7BJ,yBAAQC,GAAR,CAAY,mBAAZ;AACA,qBAAII,gBAAgBC,KAAKC,KAAL,CAAWH,QAAQI,IAAnB,CAApB;;AAEA,qBAAIH,cAAcI,YAAd,KAA+B,WAA/B,IAA8C,MAAKZ,cAAvD,EAAuE;AACnE;AACH;;AAED,uBAAKD,QAAL,CAAcQ,OAAd,EAAuB,MAAKN,OAA5B;AACH,cATD;;AAWA,kBAAKI,EAAL,CAAQQ,MAAR,GAAiB,YAAM;AACnBV,yBAAQC,GAAR,CAAY,+DAAZ;AACH,cAFD;;AAIA,kBAAKC,EAAL,CAAQS,IAAR;AACH;;;;;;mBA9BgBhB,gB;AA+BpB,E;;;;;;ACjCD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAsD,uCAAuC;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;AACA,EAAC;;AAED;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,wBAAuB,cAAc;;AAErC;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,iFAAgF;AAChF;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,qEAAoE,oBAAoB,EAAE;AAC1F,qEAAoE,qBAAqB,EAAE;AAC3F,qEAAoE,0BAA0B,EAAE;AAChG,qEAAoE,uBAAuB,EAAE;AAC7F,qEAAoE,qBAAqB,EAAE;;AAE3F;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,EAAC","file":"certstream.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CertStream\"] = factory();\n\telse\n\t\troot[\"CertStream\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 1ebd651b81469407348b","import ReconnectingWebsocket from \"reconnectingwebsocket\"\n\nexport default class CertStreamClient{\n constructor(callback, skipHeartbeats = false) {\n this.context = {};\n this.callback = callback;\n this.skipHeartbeats = skipHeartbeats;\n }\n\n connect(url=\"wss://certstream.calidog.io/\"){\n console.log(`Connecting to ${url}...`);\n\n this.ws = new ReconnectingWebsocket(url);\n\n console.log(\"Created ws -> \", this.ws);\n\n this.ws.onmessage = (message) => {\n console.log(\"onmessage called!\");\n let parsedMessage = JSON.parse(message.data);\n\n if (parsedMessage.message_type === \"heartbeat\" && this.skipHeartbeats) {\n return\n }\n\n this.callback(message, this.context)\n };\n\n this.ws.onopen = () => {\n console.log(\"Connection established to certstream! Waiting for messages...\");\n }\n\n this.ws.open();\n }\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/browser.js","// MIT License:\n//\n// Copyright (c) 2010-2012, Joe Walnes\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/**\n * This behaves like a WebSocket in every way, except if it fails to connect,\n * or it gets disconnected, it will repeatedly poll until it successfully connects\n * again.\n *\n * It is API compatible, so when you have:\n * ws = new WebSocket('ws://....');\n * you can replace with:\n * ws = new ReconnectingWebSocket('ws://....');\n *\n * The event stream will typically look like:\n * onconnecting\n * onopen\n * onmessage\n * onmessage\n * onclose // lost connection\n * onconnecting\n * onopen // sometime later...\n * onmessage\n * onmessage\n * etc...\n *\n * It is API compatible with the standard WebSocket API, apart from the following members:\n *\n * - `bufferedAmount`\n * - `extensions`\n * - `binaryType`\n *\n * Latest version: https://github.com/joewalnes/reconnecting-websocket/\n * - Joe Walnes\n *\n * Syntax\n * ======\n * var socket = new ReconnectingWebSocket(url, protocols, options);\n *\n * Parameters\n * ==========\n * url - The url you are connecting to.\n * protocols - Optional string or array of protocols.\n * options - See below\n *\n * Options\n * =======\n * Options can either be passed upon instantiation or set after instantiation:\n *\n * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });\n *\n * or\n *\n * var socket = new ReconnectingWebSocket(url);\n * socket.debug = true;\n * socket.reconnectInterval = 4000;\n *\n * debug\n * - Whether this instance should log debug messages. Accepts true or false. Default: false.\n *\n * automaticOpen\n * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n *\n * reconnectInterval\n * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.\n *\n * maxReconnectInterval\n * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.\n *\n * reconnectDecay\n * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.\n *\n * timeoutInterval\n * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.\n *\n */\n(function (global, factory) {\n if (typeof define === 'function' && define.amd) {\n define([], factory);\n } else if (typeof module !== 'undefined' && module.exports){\n module.exports = factory();\n } else {\n global.ReconnectingWebSocket = factory();\n }\n})(this, function () {\n\n if (!('WebSocket' in window)) {\n return;\n }\n\n function ReconnectingWebSocket(url, protocols, options) {\n\n // Default settings\n var settings = {\n\n /** Whether this instance should log debug messages. */\n debug: false,\n\n /** Whether or not the websocket should attempt to connect immediately upon instantiation. */\n automaticOpen: true,\n\n /** The number of milliseconds to delay before attempting to reconnect. */\n reconnectInterval: 1000,\n /** The maximum number of milliseconds to delay a reconnection attempt. */\n maxReconnectInterval: 30000,\n /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */\n reconnectDecay: 1.5,\n\n /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */\n timeoutInterval: 2000,\n\n /** The maximum number of reconnection attempts to make. Unlimited if null. */\n maxReconnectAttempts: null\n }\n if (!options) { options = {}; }\n\n // Overwrite and define settings with options if they exist.\n for (var key in settings) {\n if (typeof options[key] !== 'undefined') {\n this[key] = options[key];\n } else {\n this[key] = settings[key];\n }\n }\n\n // These should be treated as read-only properties\n\n /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */\n this.url = url;\n\n /** The number of attempted reconnects since starting, or the last successful connection. Read only. */\n this.reconnectAttempts = 0;\n\n /**\n * The current state of the connection.\n * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED\n * Read only.\n */\n this.readyState = WebSocket.CONNECTING;\n\n /**\n * A string indicating the name of the sub-protocol the server selected; this will be one of\n * the strings specified in the protocols parameter when creating the WebSocket object.\n * Read only.\n */\n this.protocol = null;\n\n // Private state variables\n\n var self = this;\n var ws;\n var forcedClose = false;\n var timedOut = false;\n var eventTarget = document.createElement('div');\n\n // Wire up \"on*\" properties as event handlers\n\n eventTarget.addEventListener('open', function(event) { self.onopen(event); });\n eventTarget.addEventListener('close', function(event) { self.onclose(event); });\n eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });\n eventTarget.addEventListener('message', function(event) { self.onmessage(event); });\n eventTarget.addEventListener('error', function(event) { self.onerror(event); });\n\n // Expose the API required by EventTarget\n\n this.addEventListener = eventTarget.addEventListener.bind(eventTarget);\n this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);\n this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);\n\n /**\n * This function generates an event that is compatible with standard\n * compliant browsers and IE9 - IE11\n *\n * This will prevent the error:\n * Object doesn't support this action\n *\n * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563\n * @param s String The name that the event should use\n * @param args Object an optional object that the event will use\n */\n function generateEvent(s, args) {\n \tvar evt = document.createEvent(\"CustomEvent\");\n \tevt.initCustomEvent(s, false, false, args);\n \treturn evt;\n };\n\n this.open = function (reconnectAttempt) {\n ws = new WebSocket(self.url, protocols || []);\n\n if (reconnectAttempt) {\n if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {\n return;\n }\n } else {\n eventTarget.dispatchEvent(generateEvent('connecting'));\n this.reconnectAttempts = 0;\n }\n\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);\n }\n\n var localWs = ws;\n var timeout = setTimeout(function() {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);\n }\n timedOut = true;\n localWs.close();\n timedOut = false;\n }, self.timeoutInterval);\n\n ws.onopen = function(event) {\n clearTimeout(timeout);\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onopen', self.url);\n }\n self.protocol = ws.protocol;\n self.readyState = WebSocket.OPEN;\n self.reconnectAttempts = 0;\n var e = generateEvent('open');\n e.isReconnect = reconnectAttempt;\n reconnectAttempt = false;\n eventTarget.dispatchEvent(e);\n };\n\n ws.onclose = function(event) {\n clearTimeout(timeout);\n ws = null;\n if (forcedClose) {\n self.readyState = WebSocket.CLOSED;\n eventTarget.dispatchEvent(generateEvent('close'));\n } else {\n self.readyState = WebSocket.CONNECTING;\n var e = generateEvent('connecting');\n e.code = event.code;\n e.reason = event.reason;\n e.wasClean = event.wasClean;\n eventTarget.dispatchEvent(e);\n if (!reconnectAttempt && !timedOut) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onclose', self.url);\n }\n eventTarget.dispatchEvent(generateEvent('close'));\n }\n\n var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);\n setTimeout(function() {\n self.reconnectAttempts++;\n self.open(true);\n }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);\n }\n };\n ws.onmessage = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);\n }\n var e = generateEvent('message');\n e.data = event.data;\n eventTarget.dispatchEvent(e);\n };\n ws.onerror = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onerror', self.url, event);\n }\n eventTarget.dispatchEvent(generateEvent('error'));\n };\n }\n\n // Whether or not to create a websocket upon instantiation\n if (this.automaticOpen == true) {\n this.open(false);\n }\n\n /**\n * Transmits data to the server over the WebSocket connection.\n *\n * @param data a text string, ArrayBuffer or Blob to send to the server.\n */\n this.send = function(data) {\n if (ws) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'send', self.url, data);\n }\n return ws.send(data);\n } else {\n throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';\n }\n };\n\n /**\n * Closes the WebSocket connection or connection attempt, if any.\n * If the connection is already CLOSED, this method does nothing.\n */\n this.close = function(code, reason) {\n // Default CLOSE_NORMAL code\n if (typeof code == 'undefined') {\n code = 1000;\n }\n forcedClose = true;\n if (ws) {\n ws.close(code, reason);\n }\n };\n\n /**\n * Additional public API method to refresh the connection if still open (close, re-open).\n * For example, if the app suspects bad data / missed heart beats, it can try to refresh.\n */\n this.refresh = function() {\n if (ws) {\n ws.close();\n }\n };\n }\n\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n * this indicates that the connection is ready to send and receive data.\n */\n ReconnectingWebSocket.prototype.onopen = function(event) {};\n /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */\n ReconnectingWebSocket.prototype.onclose = function(event) {};\n /** An event listener to be called when a connection begins being attempted. */\n ReconnectingWebSocket.prototype.onconnecting = function(event) {};\n /** An event listener to be called when a message is received from the server. */\n ReconnectingWebSocket.prototype.onmessage = function(event) {};\n /** An event listener to be called when an error occurs. */\n ReconnectingWebSocket.prototype.onerror = function(event) {};\n\n /**\n * Whether all instances of ReconnectingWebSocket should log debug messages.\n * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.\n */\n ReconnectingWebSocket.debugAll = false;\n\n ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;\n ReconnectingWebSocket.OPEN = WebSocket.OPEN;\n ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;\n ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;\n\n return ReconnectingWebSocket;\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/reconnectingwebsocket/reconnecting-websocket.js\n// module id = 1\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/certstream.min.js b/dist/certstream.min.js index 4cfc116..b951c0e 100644 --- a/dist/certstream.min.js +++ b/dist/certstream.min.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CertStream=t():e.CertStream=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var c=n[o]={exports:{},id:o,loaded:!1};return e[o].call(c.exports,c,c.exports,t),c.loaded=!0,c.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];c(this,e),this.context={},this.callback=t,this.skipHeartbeats=n}return r(e,[{key:"connect",value:function(){var e=this;console.log("Connecting..."),this.ws=new s.default("wss://certstream.calidog.io/"),console.log("Created ws -> ",this.ws),this.ws.onmessage=function(t){console.log("onmessage called!");var n=JSON.parse(t.data);"heartbeat"===n.message_type&&e.skipHeartbeats||e.callback(t,e.context)},this.ws.onopen=function(){console.log("Connection established to certstream! Waiting for messages...")},this.ws.open()}}]),e}();t.default=a},function(e,t,n){var o,c,r;!function(n,i){c=[],o=i,r="function"==typeof o?o.apply(t,c):o,!(void 0!==r&&(e.exports=r))}(this,function(){function e(t,n,o){function c(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,!1,t),n}var r={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3,maxReconnectAttempts:null};o||(o={});for(var i in r)"undefined"!=typeof o[i]?this[i]=o[i]:this[i]=r[i];this.url=t,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var s,a=this,u=!1,l=!1,d=document.createElement("div");d.addEventListener("open",function(e){a.onopen(e)}),d.addEventListener("close",function(e){a.onclose(e)}),d.addEventListener("connecting",function(e){a.onconnecting(e)}),d.addEventListener("message",function(e){a.onmessage(e)}),d.addEventListener("error",function(e){a.onerror(e)}),this.addEventListener=d.addEventListener.bind(d),this.removeEventListener=d.removeEventListener.bind(d),this.dispatchEvent=d.dispatchEvent.bind(d),this.open=function(t){if(s=new WebSocket(a.url,n||[]),t){if(this.maxReconnectAttempts&&this.reconnectAttempts>this.maxReconnectAttempts)return}else d.dispatchEvent(c("connecting")),this.reconnectAttempts=0;(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",a.url);var o=s,r=setTimeout(function(){(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",a.url),l=!0,o.close(),l=!1},a.timeoutInterval);s.onopen=function(n){clearTimeout(r),(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onopen",a.url),a.protocol=s.protocol,a.readyState=WebSocket.OPEN,a.reconnectAttempts=0;var o=c("open");o.isReconnect=t,t=!1,d.dispatchEvent(o)},s.onclose=function(n){if(clearTimeout(r),s=null,u)a.readyState=WebSocket.CLOSED,d.dispatchEvent(c("close"));else{a.readyState=WebSocket.CONNECTING;var o=c("connecting");o.code=n.code,o.reason=n.reason,o.wasClean=n.wasClean,d.dispatchEvent(o),t||l||((a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onclose",a.url),d.dispatchEvent(c("close")));var r=a.reconnectInterval*Math.pow(a.reconnectDecay,a.reconnectAttempts);setTimeout(function(){a.reconnectAttempts++,a.open(!0)},r>a.maxReconnectInterval?a.maxReconnectInterval:r)}},s.onmessage=function(t){(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",a.url,t.data);var n=c("message");n.data=t.data,d.dispatchEvent(n)},s.onerror=function(t){(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onerror",a.url,t),d.dispatchEvent(c("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(t){if(s)return(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","send",a.url,t),s.send(t);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(e,t){"undefined"==typeof e&&(e=1e3),u=!0,s&&s.close(e,t)},this.refresh=function(){s&&s.close()}}if("WebSocket"in window)return e.prototype.onopen=function(e){},e.prototype.onclose=function(e){},e.prototype.onconnecting=function(e){},e.prototype.onmessage=function(e){},e.prototype.onerror=function(e){},e.debugAll=!1,e.CONNECTING=WebSocket.CONNECTING,e.OPEN=WebSocket.OPEN,e.CLOSING=WebSocket.CLOSING,e.CLOSED=WebSocket.CLOSED,e})}])}); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.CertStream=t():e.CertStream=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var c=n[o]={exports:{},id:o,loaded:!1};return e[o].call(c.exports,c,c.exports,t),c.loaded=!0,c.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n1&&void 0!==arguments[1]&&arguments[1];c(this,e),this.context={},this.callback=t,this.skipHeartbeats=n}return r(e,[{key:"connect",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"wss://certstream.calidog.io/";console.log("Connecting to "+t+"..."),this.ws=new s.default(t),console.log("Created ws -> ",this.ws),this.ws.onmessage=function(t){console.log("onmessage called!");var n=JSON.parse(t.data);"heartbeat"===n.message_type&&e.skipHeartbeats||e.callback(t,e.context)},this.ws.onopen=function(){console.log("Connection established to certstream! Waiting for messages...")},this.ws.open()}}]),e}();t.default=a},function(e,t,n){var o,c,r;!function(n,i){c=[],o=i,r="function"==typeof o?o.apply(t,c):o,!(void 0!==r&&(e.exports=r))}(this,function(){function e(t,n,o){function c(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!1,!1,t),n}var r={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3,maxReconnectAttempts:null};o||(o={});for(var i in r)"undefined"!=typeof o[i]?this[i]=o[i]:this[i]=r[i];this.url=t,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var s,a=this,u=!1,l=!1,d=document.createElement("div");d.addEventListener("open",function(e){a.onopen(e)}),d.addEventListener("close",function(e){a.onclose(e)}),d.addEventListener("connecting",function(e){a.onconnecting(e)}),d.addEventListener("message",function(e){a.onmessage(e)}),d.addEventListener("error",function(e){a.onerror(e)}),this.addEventListener=d.addEventListener.bind(d),this.removeEventListener=d.removeEventListener.bind(d),this.dispatchEvent=d.dispatchEvent.bind(d),this.open=function(t){if(s=new WebSocket(a.url,n||[]),t){if(this.maxReconnectAttempts&&this.reconnectAttempts>this.maxReconnectAttempts)return}else d.dispatchEvent(c("connecting")),this.reconnectAttempts=0;(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",a.url);var o=s,r=setTimeout(function(){(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",a.url),l=!0,o.close(),l=!1},a.timeoutInterval);s.onopen=function(n){clearTimeout(r),(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onopen",a.url),a.protocol=s.protocol,a.readyState=WebSocket.OPEN,a.reconnectAttempts=0;var o=c("open");o.isReconnect=t,t=!1,d.dispatchEvent(o)},s.onclose=function(n){if(clearTimeout(r),s=null,u)a.readyState=WebSocket.CLOSED,d.dispatchEvent(c("close"));else{a.readyState=WebSocket.CONNECTING;var o=c("connecting");o.code=n.code,o.reason=n.reason,o.wasClean=n.wasClean,d.dispatchEvent(o),t||l||((a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onclose",a.url),d.dispatchEvent(c("close")));var r=a.reconnectInterval*Math.pow(a.reconnectDecay,a.reconnectAttempts);setTimeout(function(){a.reconnectAttempts++,a.open(!0)},r>a.maxReconnectInterval?a.maxReconnectInterval:r)}},s.onmessage=function(t){(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",a.url,t.data);var n=c("message");n.data=t.data,d.dispatchEvent(n)},s.onerror=function(t){(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","onerror",a.url,t),d.dispatchEvent(c("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(t){if(s)return(a.debug||e.debugAll)&&console.debug("ReconnectingWebSocket","send",a.url,t),s.send(t);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(e,t){"undefined"==typeof e&&(e=1e3),u=!0,s&&s.close(e,t)},this.refresh=function(){s&&s.close()}}if("WebSocket"in window)return e.prototype.onopen=function(e){},e.prototype.onclose=function(e){},e.prototype.onconnecting=function(e){},e.prototype.onmessage=function(e){},e.prototype.onerror=function(e){},e.debugAll=!1,e.CONNECTING=WebSocket.CONNECTING,e.OPEN=WebSocket.OPEN,e.CLOSING=WebSocket.CLOSING,e.CLOSED=WebSocket.CLOSED,e})}])}); //# sourceMappingURL=certstream.min.js.map \ No newline at end of file diff --git a/dist/certstream.min.js.map b/dist/certstream.min.js.map index eebc2b1..0576e4f 100644 --- a/dist/certstream.min.js.map +++ b/dist/certstream.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///certstream.min.js","webpack:///webpack/bootstrap 64fedfcedc1df0bab8bf","webpack:///./src/browser.js","webpack:///./~/reconnectingwebsocket/reconnecting-websocket.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_interopRequireDefault","obj","__esModule","default","_classCallCheck","instance","Constructor","TypeError","Object","defineProperty","value","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","key","protoProps","staticProps","prototype","_reconnectingwebsocket","_reconnectingwebsocket2","CertStreamClient","callback","skipHeartbeats","arguments","undefined","context","_this","console","log","ws","onmessage","message","parsedMessage","JSON","parse","data","message_type","onopen","open","__WEBPACK_AMD_DEFINE_FACTORY__","__WEBPACK_AMD_DEFINE_ARRAY__","__WEBPACK_AMD_DEFINE_RESULT__","global","apply","ReconnectingWebSocket","url","protocols","options","generateEvent","s","args","evt","document","createEvent","initCustomEvent","settings","debug","automaticOpen","reconnectInterval","maxReconnectInterval","reconnectDecay","timeoutInterval","maxReconnectAttempts","reconnectAttempts","readyState","WebSocket","CONNECTING","protocol","self","forcedClose","timedOut","eventTarget","createElement","addEventListener","event","onclose","onconnecting","onerror","bind","removeEventListener","dispatchEvent","reconnectAttempt","debugAll","localWs","timeout","setTimeout","close","clearTimeout","OPEN","e","isReconnect","CLOSED","code","reason","wasClean","Math","pow","send","refresh","window","CLOSING"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,WAAAD,IAEAD,EAAA,WAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP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EAAAwD,QAAAnC,UAAAmC,QACAxD,EAAA+C,OAAA1B,UAAA0B,OAEA/C","file":"certstream.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CertStream\"] = factory();\n\telse\n\t\troot[\"CertStream\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CertStream\"] = factory();\n\telse\n\t\troot[\"CertStream\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _reconnectingwebsocket = __webpack_require__(1);\n\t\n\tvar _reconnectingwebsocket2 = _interopRequireDefault(_reconnectingwebsocket);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\tvar CertStreamClient = function () {\n\t function CertStreamClient(callback) {\n\t var skipHeartbeats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\t\n\t _classCallCheck(this, CertStreamClient);\n\t\n\t this.context = {};\n\t this.callback = callback;\n\t this.skipHeartbeats = skipHeartbeats;\n\t }\n\t\n\t _createClass(CertStreamClient, [{\n\t key: \"connect\",\n\t value: function connect() {\n\t var _this = this;\n\t\n\t console.log(\"Connecting...\");\n\t\n\t this.ws = new _reconnectingwebsocket2.default(\"wss://certstream.calidog.io/\");\n\t\n\t console.log(\"Created ws -> \", this.ws);\n\t\n\t this.ws.onmessage = function (message) {\n\t console.log(\"onmessage called!\");\n\t var parsedMessage = JSON.parse(message.data);\n\t\n\t if (parsedMessage.message_type === \"heartbeat\" && _this.skipHeartbeats) {\n\t return;\n\t }\n\t\n\t _this.callback(message, _this.context);\n\t };\n\t\n\t this.ws.onopen = function () {\n\t console.log(\"Connection established to certstream! Waiting for messages...\");\n\t };\n\t\n\t this.ws.open();\n\t }\n\t }]);\n\t\n\t return CertStreamClient;\n\t}();\n\t\n\texports.default = CertStreamClient;\n\t;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// MIT License:\n\t//\n\t// Copyright (c) 2010-2012, Joe Walnes\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a copy\n\t// of this software and associated documentation files (the \"Software\"), to deal\n\t// in the Software without restriction, including without limitation the rights\n\t// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\t// copies of the Software, and to permit persons to whom the Software is\n\t// furnished to do so, subject to the following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included in\n\t// all copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\t// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\t// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\t// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\t// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\t// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\t// THE SOFTWARE.\n\t\n\t/**\n\t * This behaves like a WebSocket in every way, except if it fails to connect,\n\t * or it gets disconnected, it will repeatedly poll until it successfully connects\n\t * again.\n\t *\n\t * It is API compatible, so when you have:\n\t * ws = new WebSocket('ws://....');\n\t * you can replace with:\n\t * ws = new ReconnectingWebSocket('ws://....');\n\t *\n\t * The event stream will typically look like:\n\t * onconnecting\n\t * onopen\n\t * onmessage\n\t * onmessage\n\t * onclose // lost connection\n\t * onconnecting\n\t * onopen // sometime later...\n\t * onmessage\n\t * onmessage\n\t * etc...\n\t *\n\t * It is API compatible with the standard WebSocket API, apart from the following members:\n\t *\n\t * - `bufferedAmount`\n\t * - `extensions`\n\t * - `binaryType`\n\t *\n\t * Latest version: https://github.com/joewalnes/reconnecting-websocket/\n\t * - Joe Walnes\n\t *\n\t * Syntax\n\t * ======\n\t * var socket = new ReconnectingWebSocket(url, protocols, options);\n\t *\n\t * Parameters\n\t * ==========\n\t * url - The url you are connecting to.\n\t * protocols - Optional string or array of protocols.\n\t * options - See below\n\t *\n\t * Options\n\t * =======\n\t * Options can either be passed upon instantiation or set after instantiation:\n\t *\n\t * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });\n\t *\n\t * or\n\t *\n\t * var socket = new ReconnectingWebSocket(url);\n\t * socket.debug = true;\n\t * socket.reconnectInterval = 4000;\n\t *\n\t * debug\n\t * - Whether this instance should log debug messages. Accepts true or false. Default: false.\n\t *\n\t * automaticOpen\n\t * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n\t *\n\t * reconnectInterval\n\t * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.\n\t *\n\t * maxReconnectInterval\n\t * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.\n\t *\n\t * reconnectDecay\n\t * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.\n\t *\n\t * timeoutInterval\n\t * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.\n\t *\n\t */\n\t(function (global, factory) {\n\t if (true) {\n\t !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n\t } else if (typeof module !== 'undefined' && module.exports){\n\t module.exports = factory();\n\t } else {\n\t global.ReconnectingWebSocket = factory();\n\t }\n\t})(this, function () {\n\t\n\t if (!('WebSocket' in window)) {\n\t return;\n\t }\n\t\n\t function ReconnectingWebSocket(url, protocols, options) {\n\t\n\t // Default settings\n\t var settings = {\n\t\n\t /** Whether this instance should log debug messages. */\n\t debug: false,\n\t\n\t /** Whether or not the websocket should attempt to connect immediately upon instantiation. */\n\t automaticOpen: true,\n\t\n\t /** The number of milliseconds to delay before attempting to reconnect. */\n\t reconnectInterval: 1000,\n\t /** The maximum number of milliseconds to delay a reconnection attempt. */\n\t maxReconnectInterval: 30000,\n\t /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */\n\t reconnectDecay: 1.5,\n\t\n\t /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */\n\t timeoutInterval: 2000,\n\t\n\t /** The maximum number of reconnection attempts to make. Unlimited if null. */\n\t maxReconnectAttempts: null\n\t }\n\t if (!options) { options = {}; }\n\t\n\t // Overwrite and define settings with options if they exist.\n\t for (var key in settings) {\n\t if (typeof options[key] !== 'undefined') {\n\t this[key] = options[key];\n\t } else {\n\t this[key] = settings[key];\n\t }\n\t }\n\t\n\t // These should be treated as read-only properties\n\t\n\t /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */\n\t this.url = url;\n\t\n\t /** The number of attempted reconnects since starting, or the last successful connection. Read only. */\n\t this.reconnectAttempts = 0;\n\t\n\t /**\n\t * The current state of the connection.\n\t * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED\n\t * Read only.\n\t */\n\t this.readyState = WebSocket.CONNECTING;\n\t\n\t /**\n\t * A string indicating the name of the sub-protocol the server selected; this will be one of\n\t * the strings specified in the protocols parameter when creating the WebSocket object.\n\t * Read only.\n\t */\n\t this.protocol = null;\n\t\n\t // Private state variables\n\t\n\t var self = this;\n\t var ws;\n\t var forcedClose = false;\n\t var timedOut = false;\n\t var eventTarget = document.createElement('div');\n\t\n\t // Wire up \"on*\" properties as event handlers\n\t\n\t eventTarget.addEventListener('open', function(event) { self.onopen(event); });\n\t eventTarget.addEventListener('close', function(event) { self.onclose(event); });\n\t eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });\n\t eventTarget.addEventListener('message', function(event) { self.onmessage(event); });\n\t eventTarget.addEventListener('error', function(event) { self.onerror(event); });\n\t\n\t // Expose the API required by EventTarget\n\t\n\t this.addEventListener = eventTarget.addEventListener.bind(eventTarget);\n\t this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);\n\t this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);\n\t\n\t /**\n\t * This function generates an event that is compatible with standard\n\t * compliant browsers and IE9 - IE11\n\t *\n\t * This will prevent the error:\n\t * Object doesn't support this action\n\t *\n\t * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563\n\t * @param s String The name that the event should use\n\t * @param args Object an optional object that the event will use\n\t */\n\t function generateEvent(s, args) {\n\t \tvar evt = document.createEvent(\"CustomEvent\");\n\t \tevt.initCustomEvent(s, false, false, args);\n\t \treturn evt;\n\t };\n\t\n\t this.open = function (reconnectAttempt) {\n\t ws = new WebSocket(self.url, protocols || []);\n\t\n\t if (reconnectAttempt) {\n\t if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {\n\t return;\n\t }\n\t } else {\n\t eventTarget.dispatchEvent(generateEvent('connecting'));\n\t this.reconnectAttempts = 0;\n\t }\n\t\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);\n\t }\n\t\n\t var localWs = ws;\n\t var timeout = setTimeout(function() {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);\n\t }\n\t timedOut = true;\n\t localWs.close();\n\t timedOut = false;\n\t }, self.timeoutInterval);\n\t\n\t ws.onopen = function(event) {\n\t clearTimeout(timeout);\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onopen', self.url);\n\t }\n\t self.protocol = ws.protocol;\n\t self.readyState = WebSocket.OPEN;\n\t self.reconnectAttempts = 0;\n\t var e = generateEvent('open');\n\t e.isReconnect = reconnectAttempt;\n\t reconnectAttempt = false;\n\t eventTarget.dispatchEvent(e);\n\t };\n\t\n\t ws.onclose = function(event) {\n\t clearTimeout(timeout);\n\t ws = null;\n\t if (forcedClose) {\n\t self.readyState = WebSocket.CLOSED;\n\t eventTarget.dispatchEvent(generateEvent('close'));\n\t } else {\n\t self.readyState = WebSocket.CONNECTING;\n\t var e = generateEvent('connecting');\n\t e.code = event.code;\n\t e.reason = event.reason;\n\t e.wasClean = event.wasClean;\n\t eventTarget.dispatchEvent(e);\n\t if (!reconnectAttempt && !timedOut) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onclose', self.url);\n\t }\n\t eventTarget.dispatchEvent(generateEvent('close'));\n\t }\n\t\n\t var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);\n\t setTimeout(function() {\n\t self.reconnectAttempts++;\n\t self.open(true);\n\t }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);\n\t }\n\t };\n\t ws.onmessage = function(event) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);\n\t }\n\t var e = generateEvent('message');\n\t e.data = event.data;\n\t eventTarget.dispatchEvent(e);\n\t };\n\t ws.onerror = function(event) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onerror', self.url, event);\n\t }\n\t eventTarget.dispatchEvent(generateEvent('error'));\n\t };\n\t }\n\t\n\t // Whether or not to create a websocket upon instantiation\n\t if (this.automaticOpen == true) {\n\t this.open(false);\n\t }\n\t\n\t /**\n\t * Transmits data to the server over the WebSocket connection.\n\t *\n\t * @param data a text string, ArrayBuffer or Blob to send to the server.\n\t */\n\t this.send = function(data) {\n\t if (ws) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'send', self.url, data);\n\t }\n\t return ws.send(data);\n\t } else {\n\t throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';\n\t }\n\t };\n\t\n\t /**\n\t * Closes the WebSocket connection or connection attempt, if any.\n\t * If the connection is already CLOSED, this method does nothing.\n\t */\n\t this.close = function(code, reason) {\n\t // Default CLOSE_NORMAL code\n\t if (typeof code == 'undefined') {\n\t code = 1000;\n\t }\n\t forcedClose = true;\n\t if (ws) {\n\t ws.close(code, reason);\n\t }\n\t };\n\t\n\t /**\n\t * Additional public API method to refresh the connection if still open (close, re-open).\n\t * For example, if the app suspects bad data / missed heart beats, it can try to refresh.\n\t */\n\t this.refresh = function() {\n\t if (ws) {\n\t ws.close();\n\t }\n\t };\n\t }\n\t\n\t /**\n\t * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n\t * this indicates that the connection is ready to send and receive data.\n\t */\n\t ReconnectingWebSocket.prototype.onopen = function(event) {};\n\t /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */\n\t ReconnectingWebSocket.prototype.onclose = function(event) {};\n\t /** An event listener to be called when a connection begins being attempted. */\n\t ReconnectingWebSocket.prototype.onconnecting = function(event) {};\n\t /** An event listener to be called when a message is received from the server. */\n\t ReconnectingWebSocket.prototype.onmessage = function(event) {};\n\t /** An event listener to be called when an error occurs. */\n\t ReconnectingWebSocket.prototype.onerror = function(event) {};\n\t\n\t /**\n\t * Whether all instances of ReconnectingWebSocket should log debug messages.\n\t * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.\n\t */\n\t ReconnectingWebSocket.debugAll = false;\n\t\n\t ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;\n\t ReconnectingWebSocket.OPEN = WebSocket.OPEN;\n\t ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;\n\t ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;\n\t\n\t return ReconnectingWebSocket;\n\t});\n\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// certstream.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 64fedfcedc1df0bab8bf","import ReconnectingWebsocket from \"reconnectingwebsocket\"\n\nexport default class CertStreamClient{\n constructor(callback, skipHeartbeats = false) {\n this.context = {};\n this.callback = callback;\n this.skipHeartbeats = skipHeartbeats;\n }\n\n connect(){\n console.log(\"Connecting...\");\n\n this.ws = new ReconnectingWebsocket(\"wss://certstream.calidog.io/\");\n\n console.log(\"Created ws -> \", this.ws);\n\n this.ws.onmessage = (message) => {\n console.log(\"onmessage called!\");\n let parsedMessage = JSON.parse(message.data);\n\n if (parsedMessage.message_type === \"heartbeat\" && this.skipHeartbeats) {\n return\n }\n\n this.callback(message, this.context)\n };\n\n this.ws.onopen = () => {\n console.log(\"Connection established to certstream! Waiting for messages...\");\n }\n\n this.ws.open();\n }\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/browser.js","// MIT License:\n//\n// Copyright (c) 2010-2012, Joe Walnes\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/**\n * This behaves like a WebSocket in every way, except if it fails to connect,\n * or it gets disconnected, it will repeatedly poll until it successfully connects\n * again.\n *\n * It is API compatible, so when you have:\n * ws = new WebSocket('ws://....');\n * you can replace with:\n * ws = new ReconnectingWebSocket('ws://....');\n *\n * The event stream will typically look like:\n * onconnecting\n * onopen\n * onmessage\n * onmessage\n * onclose // lost connection\n * onconnecting\n * onopen // sometime later...\n * onmessage\n * onmessage\n * etc...\n *\n * It is API compatible with the standard WebSocket API, apart from the following members:\n *\n * - `bufferedAmount`\n * - `extensions`\n * - `binaryType`\n *\n * Latest version: https://github.com/joewalnes/reconnecting-websocket/\n * - Joe Walnes\n *\n * Syntax\n * ======\n * var socket = new ReconnectingWebSocket(url, protocols, options);\n *\n * Parameters\n * ==========\n * url - The url you are connecting to.\n * protocols - Optional string or array of protocols.\n * options - See below\n *\n * Options\n * =======\n * Options can either be passed upon instantiation or set after instantiation:\n *\n * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });\n *\n * or\n *\n * var socket = new ReconnectingWebSocket(url);\n * socket.debug = true;\n * socket.reconnectInterval = 4000;\n *\n * debug\n * - Whether this instance should log debug messages. Accepts true or false. Default: false.\n *\n * automaticOpen\n * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n *\n * reconnectInterval\n * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.\n *\n * maxReconnectInterval\n * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.\n *\n * reconnectDecay\n * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.\n *\n * timeoutInterval\n * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.\n *\n */\n(function (global, factory) {\n if (typeof define === 'function' && define.amd) {\n define([], factory);\n } else if (typeof module !== 'undefined' && module.exports){\n module.exports = factory();\n } else {\n global.ReconnectingWebSocket = factory();\n }\n})(this, function () {\n\n if (!('WebSocket' in window)) {\n return;\n }\n\n function ReconnectingWebSocket(url, protocols, options) {\n\n // Default settings\n var settings = {\n\n /** Whether this instance should log debug messages. */\n debug: false,\n\n /** Whether or not the websocket should attempt to connect immediately upon instantiation. */\n automaticOpen: true,\n\n /** The number of milliseconds to delay before attempting to reconnect. */\n reconnectInterval: 1000,\n /** The maximum number of milliseconds to delay a reconnection attempt. */\n maxReconnectInterval: 30000,\n /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */\n reconnectDecay: 1.5,\n\n /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */\n timeoutInterval: 2000,\n\n /** The maximum number of reconnection attempts to make. Unlimited if null. */\n maxReconnectAttempts: null\n }\n if (!options) { options = {}; }\n\n // Overwrite and define settings with options if they exist.\n for (var key in settings) {\n if (typeof options[key] !== 'undefined') {\n this[key] = options[key];\n } else {\n this[key] = settings[key];\n }\n }\n\n // These should be treated as read-only properties\n\n /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */\n this.url = url;\n\n /** The number of attempted reconnects since starting, or the last successful connection. Read only. */\n this.reconnectAttempts = 0;\n\n /**\n * The current state of the connection.\n * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED\n * Read only.\n */\n this.readyState = WebSocket.CONNECTING;\n\n /**\n * A string indicating the name of the sub-protocol the server selected; this will be one of\n * the strings specified in the protocols parameter when creating the WebSocket object.\n * Read only.\n */\n this.protocol = null;\n\n // Private state variables\n\n var self = this;\n var ws;\n var forcedClose = false;\n var timedOut = false;\n var eventTarget = document.createElement('div');\n\n // Wire up \"on*\" properties as event handlers\n\n eventTarget.addEventListener('open', function(event) { self.onopen(event); });\n eventTarget.addEventListener('close', function(event) { self.onclose(event); });\n eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });\n eventTarget.addEventListener('message', function(event) { self.onmessage(event); });\n eventTarget.addEventListener('error', function(event) { self.onerror(event); });\n\n // Expose the API required by EventTarget\n\n this.addEventListener = eventTarget.addEventListener.bind(eventTarget);\n this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);\n this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);\n\n /**\n * This function generates an event that is compatible with standard\n * compliant browsers and IE9 - IE11\n *\n * This will prevent the error:\n * Object doesn't support this action\n *\n * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563\n * @param s String The name that the event should use\n * @param args Object an optional object that the event will use\n */\n function generateEvent(s, args) {\n \tvar evt = document.createEvent(\"CustomEvent\");\n \tevt.initCustomEvent(s, false, false, args);\n \treturn evt;\n };\n\n this.open = function (reconnectAttempt) {\n ws = new WebSocket(self.url, protocols || []);\n\n if (reconnectAttempt) {\n if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {\n return;\n }\n } else {\n eventTarget.dispatchEvent(generateEvent('connecting'));\n this.reconnectAttempts = 0;\n }\n\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);\n }\n\n var localWs = ws;\n var timeout = setTimeout(function() {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);\n }\n timedOut = true;\n localWs.close();\n timedOut = false;\n }, self.timeoutInterval);\n\n ws.onopen = function(event) {\n clearTimeout(timeout);\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onopen', self.url);\n }\n self.protocol = ws.protocol;\n self.readyState = WebSocket.OPEN;\n self.reconnectAttempts = 0;\n var e = generateEvent('open');\n e.isReconnect = reconnectAttempt;\n reconnectAttempt = false;\n eventTarget.dispatchEvent(e);\n };\n\n ws.onclose = function(event) {\n clearTimeout(timeout);\n ws = null;\n if (forcedClose) {\n self.readyState = WebSocket.CLOSED;\n eventTarget.dispatchEvent(generateEvent('close'));\n } else {\n self.readyState = WebSocket.CONNECTING;\n var e = generateEvent('connecting');\n e.code = event.code;\n e.reason = event.reason;\n e.wasClean = event.wasClean;\n eventTarget.dispatchEvent(e);\n if (!reconnectAttempt && !timedOut) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onclose', self.url);\n }\n eventTarget.dispatchEvent(generateEvent('close'));\n }\n\n var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);\n setTimeout(function() {\n self.reconnectAttempts++;\n self.open(true);\n }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);\n }\n };\n ws.onmessage = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);\n }\n var e = generateEvent('message');\n e.data = event.data;\n eventTarget.dispatchEvent(e);\n };\n ws.onerror = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onerror', self.url, event);\n }\n eventTarget.dispatchEvent(generateEvent('error'));\n };\n }\n\n // Whether or not to create a websocket upon instantiation\n if (this.automaticOpen == true) {\n this.open(false);\n }\n\n /**\n * Transmits data to the server over the WebSocket connection.\n *\n * @param data a text string, ArrayBuffer or Blob to send to the server.\n */\n this.send = function(data) {\n if (ws) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'send', self.url, data);\n }\n return ws.send(data);\n } else {\n throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';\n }\n };\n\n /**\n * Closes the WebSocket connection or connection attempt, if any.\n * If the connection is already CLOSED, this method does nothing.\n */\n this.close = function(code, reason) {\n // Default CLOSE_NORMAL code\n if (typeof code == 'undefined') {\n code = 1000;\n }\n forcedClose = true;\n if (ws) {\n ws.close(code, reason);\n }\n };\n\n /**\n * Additional public API method to refresh the connection if still open (close, re-open).\n * For example, if the app suspects bad data / missed heart beats, it can try to refresh.\n */\n this.refresh = function() {\n if (ws) {\n ws.close();\n }\n };\n }\n\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n * this indicates that the connection is ready to send and receive data.\n */\n ReconnectingWebSocket.prototype.onopen = function(event) {};\n /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */\n ReconnectingWebSocket.prototype.onclose = function(event) {};\n /** An event listener to be called when a connection begins being attempted. */\n ReconnectingWebSocket.prototype.onconnecting = function(event) {};\n /** An event listener to be called when a message is received from the server. */\n ReconnectingWebSocket.prototype.onmessage = function(event) {};\n /** An event listener to be called when an error occurs. */\n ReconnectingWebSocket.prototype.onerror = function(event) {};\n\n /**\n * Whether all instances of ReconnectingWebSocket should log debug messages.\n * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.\n */\n ReconnectingWebSocket.debugAll = false;\n\n ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;\n ReconnectingWebSocket.OPEN = WebSocket.OPEN;\n ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;\n ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;\n\n return ReconnectingWebSocket;\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/reconnectingwebsocket/reconnecting-websocket.js\n// module id = 1\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///certstream.min.js","webpack:///webpack/bootstrap 3a2c13df4cae75f5368b","webpack:///./src/browser.js","webpack:///./~/reconnectingwebsocket/reconnecting-websocket.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","_interopRequireDefault","obj","__esModule","default","_classCallCheck","instance","Constructor","TypeError","Object","defineProperty","value","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","key","protoProps","staticProps","prototype","_reconnectingwebsocket","_reconnectingwebsocket2","CertStreamClient","callback","skipHeartbeats","arguments","undefined","context","_this","url","console","log","ws","onmessage","message","parsedMessage","JSON","parse","data","message_type","onopen","open","__WEBPACK_AMD_DEFINE_FACTORY__","__WEBPACK_AMD_DEFINE_ARRAY__","__WEBPACK_AMD_DEFINE_RESULT__","global","apply","ReconnectingWebSocket","protocols","options","generateEvent","s","args","evt","document","createEvent","initCustomEvent","settings","debug","automaticOpen","reconnectInterval","maxReconnectInterval","reconnectDecay","timeoutInterval","maxReconnectAttempts","reconnectAttempts","readyState","WebSocket","CONNECTING","protocol","self","forcedClose","timedOut","eventTarget","createElement","addEventListener","event","onclose","onconnecting","onerror","bind","removeEventListener","dispatchEvent","reconnectAttempt","debugAll","localWs","timeout","setTimeout","close","clearTimeout","OPEN","e","isReconnect","CLOSED","code","reason","wasClean","Math","pow","send","refresh","window","CLOSING"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,WAAAD,IAEAD,EAAA,WAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAAUL,EAAQD,EAASM,GAEhC,YAYA,SAASS,GAAuBC,GAAO,MAAOA,IAAOA,EAAIC,WAAaD,GAAQE,QAASF,GAEvF,QAASG,GAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAZhHC,OAAOC,eAAexB,EAAS,cAC3ByB,OAAO,GAGX,IAAIC,GAAe,WAAc,QAASC,GAAiBC,EAAQC,GAAS,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,GAAIE,GAAaH,EAAMC,EAAIE,GAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,SAAWF,KAAYA,EAAWG,UAAW,GAAMZ,OAAOC,eAAeI,EAAQI,EAAWI,IAAKJ,IAAiB,MAA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AqC,WACAtD,QAAA4B,MAAA,kCAAAY,EAAAzC,IAAA+C,GAEAH,EAAAS,cAAAhC,EAAA,YAKA,GAAAlE,KAAA2E,eACA3E,KAAAyD,MAAA,GAQAzD,KAAAmH,KAAA,SAAA7D,GACA,GAAAN,EAIA,OAHAsC,EAAAZ,OAAAX,EAAAqC,WACAtD,QAAA4B,MAAA,+BAAAY,EAAAzC,IAAAS,GAEAN,EAAAmE,KAAA7D,EAEA,4DAQAtD,KAAAwG,MAAA,SAAAM,EAAAC,GAEA,mBAAAD,KACAA,EAAA,KAEAvB,GAAA,EACAvC,GACAA,EAAAwD,MAAAM,EAAAC,IAQA/G,KAAAoH,QAAA,WACApE,GACAA,EAAAwD,SAjOA,gBAAAa,QA+PA,MArBAtD,GAAA5B,UAAAqB,OAAA,SAAAoC,KAEA7B,EAAA5B,UAAA0D,QAAA,SAAAD,KAEA7B,EAAA5B,UAAA2D,aAAA,SAAAF,KAEA7B,EAAA5B,UAAAc,UAAA,SAAA2C,KAEA7B,EAAA5B,UAAA4D,QAAA,SAAAH,KAMA7B,EAAAqC,UAAA,EAEArC,EAAAqB,WAAAD,UAAAC,WACArB,EAAA2C,KAAAvB,UAAAuB,KACA3C,EAAAuD,QAAAnC,UAAAmC,QACAvD,EAAA8C,OAAA1B,UAAA0B,OAEA9C","file":"certstream.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CertStream\"] = factory();\n\telse\n\t\troot[\"CertStream\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CertStream\"] = factory();\n\telse\n\t\troot[\"CertStream\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.loaded = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t\"use strict\";\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\t\n\tvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\t\n\tvar _reconnectingwebsocket = __webpack_require__(1);\n\t\n\tvar _reconnectingwebsocket2 = _interopRequireDefault(_reconnectingwebsocket);\n\t\n\tfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\t\n\tfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\t\n\tvar CertStreamClient = function () {\n\t function CertStreamClient(callback) {\n\t var skipHeartbeats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\t\n\t _classCallCheck(this, CertStreamClient);\n\t\n\t this.context = {};\n\t this.callback = callback;\n\t this.skipHeartbeats = skipHeartbeats;\n\t }\n\t\n\t _createClass(CertStreamClient, [{\n\t key: \"connect\",\n\t value: function connect() {\n\t var _this = this;\n\t\n\t var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"wss://certstream.calidog.io/\";\n\t\n\t console.log(\"Connecting to \" + url + \"...\");\n\t\n\t this.ws = new _reconnectingwebsocket2.default(url);\n\t\n\t console.log(\"Created ws -> \", this.ws);\n\t\n\t this.ws.onmessage = function (message) {\n\t console.log(\"onmessage called!\");\n\t var parsedMessage = JSON.parse(message.data);\n\t\n\t if (parsedMessage.message_type === \"heartbeat\" && _this.skipHeartbeats) {\n\t return;\n\t }\n\t\n\t _this.callback(message, _this.context);\n\t };\n\t\n\t this.ws.onopen = function () {\n\t console.log(\"Connection established to certstream! Waiting for messages...\");\n\t };\n\t\n\t this.ws.open();\n\t }\n\t }]);\n\t\n\t return CertStreamClient;\n\t}();\n\t\n\texports.default = CertStreamClient;\n\t;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\tvar __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// MIT License:\n\t//\n\t// Copyright (c) 2010-2012, Joe Walnes\n\t//\n\t// Permission is hereby granted, free of charge, to any person obtaining a copy\n\t// of this software and associated documentation files (the \"Software\"), to deal\n\t// in the Software without restriction, including without limitation the rights\n\t// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\t// copies of the Software, and to permit persons to whom the Software is\n\t// furnished to do so, subject to the following conditions:\n\t//\n\t// The above copyright notice and this permission notice shall be included in\n\t// all copies or substantial portions of the Software.\n\t//\n\t// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\t// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\t// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\t// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\t// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\t// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\t// THE SOFTWARE.\n\t\n\t/**\n\t * This behaves like a WebSocket in every way, except if it fails to connect,\n\t * or it gets disconnected, it will repeatedly poll until it successfully connects\n\t * again.\n\t *\n\t * It is API compatible, so when you have:\n\t * ws = new WebSocket('ws://....');\n\t * you can replace with:\n\t * ws = new ReconnectingWebSocket('ws://....');\n\t *\n\t * The event stream will typically look like:\n\t * onconnecting\n\t * onopen\n\t * onmessage\n\t * onmessage\n\t * onclose // lost connection\n\t * onconnecting\n\t * onopen // sometime later...\n\t * onmessage\n\t * onmessage\n\t * etc...\n\t *\n\t * It is API compatible with the standard WebSocket API, apart from the following members:\n\t *\n\t * - `bufferedAmount`\n\t * - `extensions`\n\t * - `binaryType`\n\t *\n\t * Latest version: https://github.com/joewalnes/reconnecting-websocket/\n\t * - Joe Walnes\n\t *\n\t * Syntax\n\t * ======\n\t * var socket = new ReconnectingWebSocket(url, protocols, options);\n\t *\n\t * Parameters\n\t * ==========\n\t * url - The url you are connecting to.\n\t * protocols - Optional string or array of protocols.\n\t * options - See below\n\t *\n\t * Options\n\t * =======\n\t * Options can either be passed upon instantiation or set after instantiation:\n\t *\n\t * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });\n\t *\n\t * or\n\t *\n\t * var socket = new ReconnectingWebSocket(url);\n\t * socket.debug = true;\n\t * socket.reconnectInterval = 4000;\n\t *\n\t * debug\n\t * - Whether this instance should log debug messages. Accepts true or false. Default: false.\n\t *\n\t * automaticOpen\n\t * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n\t *\n\t * reconnectInterval\n\t * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.\n\t *\n\t * maxReconnectInterval\n\t * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.\n\t *\n\t * reconnectDecay\n\t * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.\n\t *\n\t * timeoutInterval\n\t * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.\n\t *\n\t */\n\t(function (global, factory) {\n\t if (true) {\n\t !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n\t } else if (typeof module !== 'undefined' && module.exports){\n\t module.exports = factory();\n\t } else {\n\t global.ReconnectingWebSocket = factory();\n\t }\n\t})(this, function () {\n\t\n\t if (!('WebSocket' in window)) {\n\t return;\n\t }\n\t\n\t function ReconnectingWebSocket(url, protocols, options) {\n\t\n\t // Default settings\n\t var settings = {\n\t\n\t /** Whether this instance should log debug messages. */\n\t debug: false,\n\t\n\t /** Whether or not the websocket should attempt to connect immediately upon instantiation. */\n\t automaticOpen: true,\n\t\n\t /** The number of milliseconds to delay before attempting to reconnect. */\n\t reconnectInterval: 1000,\n\t /** The maximum number of milliseconds to delay a reconnection attempt. */\n\t maxReconnectInterval: 30000,\n\t /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */\n\t reconnectDecay: 1.5,\n\t\n\t /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */\n\t timeoutInterval: 2000,\n\t\n\t /** The maximum number of reconnection attempts to make. Unlimited if null. */\n\t maxReconnectAttempts: null\n\t }\n\t if (!options) { options = {}; }\n\t\n\t // Overwrite and define settings with options if they exist.\n\t for (var key in settings) {\n\t if (typeof options[key] !== 'undefined') {\n\t this[key] = options[key];\n\t } else {\n\t this[key] = settings[key];\n\t }\n\t }\n\t\n\t // These should be treated as read-only properties\n\t\n\t /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */\n\t this.url = url;\n\t\n\t /** The number of attempted reconnects since starting, or the last successful connection. Read only. */\n\t this.reconnectAttempts = 0;\n\t\n\t /**\n\t * The current state of the connection.\n\t * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED\n\t * Read only.\n\t */\n\t this.readyState = WebSocket.CONNECTING;\n\t\n\t /**\n\t * A string indicating the name of the sub-protocol the server selected; this will be one of\n\t * the strings specified in the protocols parameter when creating the WebSocket object.\n\t * Read only.\n\t */\n\t this.protocol = null;\n\t\n\t // Private state variables\n\t\n\t var self = this;\n\t var ws;\n\t var forcedClose = false;\n\t var timedOut = false;\n\t var eventTarget = document.createElement('div');\n\t\n\t // Wire up \"on*\" properties as event handlers\n\t\n\t eventTarget.addEventListener('open', function(event) { self.onopen(event); });\n\t eventTarget.addEventListener('close', function(event) { self.onclose(event); });\n\t eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });\n\t eventTarget.addEventListener('message', function(event) { self.onmessage(event); });\n\t eventTarget.addEventListener('error', function(event) { self.onerror(event); });\n\t\n\t // Expose the API required by EventTarget\n\t\n\t this.addEventListener = eventTarget.addEventListener.bind(eventTarget);\n\t this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);\n\t this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);\n\t\n\t /**\n\t * This function generates an event that is compatible with standard\n\t * compliant browsers and IE9 - IE11\n\t *\n\t * This will prevent the error:\n\t * Object doesn't support this action\n\t *\n\t * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563\n\t * @param s String The name that the event should use\n\t * @param args Object an optional object that the event will use\n\t */\n\t function generateEvent(s, args) {\n\t \tvar evt = document.createEvent(\"CustomEvent\");\n\t \tevt.initCustomEvent(s, false, false, args);\n\t \treturn evt;\n\t };\n\t\n\t this.open = function (reconnectAttempt) {\n\t ws = new WebSocket(self.url, protocols || []);\n\t\n\t if (reconnectAttempt) {\n\t if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {\n\t return;\n\t }\n\t } else {\n\t eventTarget.dispatchEvent(generateEvent('connecting'));\n\t this.reconnectAttempts = 0;\n\t }\n\t\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);\n\t }\n\t\n\t var localWs = ws;\n\t var timeout = setTimeout(function() {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);\n\t }\n\t timedOut = true;\n\t localWs.close();\n\t timedOut = false;\n\t }, self.timeoutInterval);\n\t\n\t ws.onopen = function(event) {\n\t clearTimeout(timeout);\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onopen', self.url);\n\t }\n\t self.protocol = ws.protocol;\n\t self.readyState = WebSocket.OPEN;\n\t self.reconnectAttempts = 0;\n\t var e = generateEvent('open');\n\t e.isReconnect = reconnectAttempt;\n\t reconnectAttempt = false;\n\t eventTarget.dispatchEvent(e);\n\t };\n\t\n\t ws.onclose = function(event) {\n\t clearTimeout(timeout);\n\t ws = null;\n\t if (forcedClose) {\n\t self.readyState = WebSocket.CLOSED;\n\t eventTarget.dispatchEvent(generateEvent('close'));\n\t } else {\n\t self.readyState = WebSocket.CONNECTING;\n\t var e = generateEvent('connecting');\n\t e.code = event.code;\n\t e.reason = event.reason;\n\t e.wasClean = event.wasClean;\n\t eventTarget.dispatchEvent(e);\n\t if (!reconnectAttempt && !timedOut) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onclose', self.url);\n\t }\n\t eventTarget.dispatchEvent(generateEvent('close'));\n\t }\n\t\n\t var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);\n\t setTimeout(function() {\n\t self.reconnectAttempts++;\n\t self.open(true);\n\t }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);\n\t }\n\t };\n\t ws.onmessage = function(event) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);\n\t }\n\t var e = generateEvent('message');\n\t e.data = event.data;\n\t eventTarget.dispatchEvent(e);\n\t };\n\t ws.onerror = function(event) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'onerror', self.url, event);\n\t }\n\t eventTarget.dispatchEvent(generateEvent('error'));\n\t };\n\t }\n\t\n\t // Whether or not to create a websocket upon instantiation\n\t if (this.automaticOpen == true) {\n\t this.open(false);\n\t }\n\t\n\t /**\n\t * Transmits data to the server over the WebSocket connection.\n\t *\n\t * @param data a text string, ArrayBuffer or Blob to send to the server.\n\t */\n\t this.send = function(data) {\n\t if (ws) {\n\t if (self.debug || ReconnectingWebSocket.debugAll) {\n\t console.debug('ReconnectingWebSocket', 'send', self.url, data);\n\t }\n\t return ws.send(data);\n\t } else {\n\t throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';\n\t }\n\t };\n\t\n\t /**\n\t * Closes the WebSocket connection or connection attempt, if any.\n\t * If the connection is already CLOSED, this method does nothing.\n\t */\n\t this.close = function(code, reason) {\n\t // Default CLOSE_NORMAL code\n\t if (typeof code == 'undefined') {\n\t code = 1000;\n\t }\n\t forcedClose = true;\n\t if (ws) {\n\t ws.close(code, reason);\n\t }\n\t };\n\t\n\t /**\n\t * Additional public API method to refresh the connection if still open (close, re-open).\n\t * For example, if the app suspects bad data / missed heart beats, it can try to refresh.\n\t */\n\t this.refresh = function() {\n\t if (ws) {\n\t ws.close();\n\t }\n\t };\n\t }\n\t\n\t /**\n\t * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n\t * this indicates that the connection is ready to send and receive data.\n\t */\n\t ReconnectingWebSocket.prototype.onopen = function(event) {};\n\t /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */\n\t ReconnectingWebSocket.prototype.onclose = function(event) {};\n\t /** An event listener to be called when a connection begins being attempted. */\n\t ReconnectingWebSocket.prototype.onconnecting = function(event) {};\n\t /** An event listener to be called when a message is received from the server. */\n\t ReconnectingWebSocket.prototype.onmessage = function(event) {};\n\t /** An event listener to be called when an error occurs. */\n\t ReconnectingWebSocket.prototype.onerror = function(event) {};\n\t\n\t /**\n\t * Whether all instances of ReconnectingWebSocket should log debug messages.\n\t * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.\n\t */\n\t ReconnectingWebSocket.debugAll = false;\n\t\n\t ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;\n\t ReconnectingWebSocket.OPEN = WebSocket.OPEN;\n\t ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;\n\t ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;\n\t\n\t return ReconnectingWebSocket;\n\t});\n\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// certstream.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 3a2c13df4cae75f5368b","import ReconnectingWebsocket from \"reconnectingwebsocket\"\n\nexport default class CertStreamClient{\n constructor(callback, skipHeartbeats = false) {\n this.context = {};\n this.callback = callback;\n this.skipHeartbeats = skipHeartbeats;\n }\n\n connect(url=\"wss://certstream.calidog.io/\"){\n console.log(`Connecting to ${url}...`);\n\n this.ws = new ReconnectingWebsocket(url);\n\n console.log(\"Created ws -> \", this.ws);\n\n this.ws.onmessage = (message) => {\n console.log(\"onmessage called!\");\n let parsedMessage = JSON.parse(message.data);\n\n if (parsedMessage.message_type === \"heartbeat\" && this.skipHeartbeats) {\n return\n }\n\n this.callback(message, this.context)\n };\n\n this.ws.onopen = () => {\n console.log(\"Connection established to certstream! Waiting for messages...\");\n }\n\n this.ws.open();\n }\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/browser.js","// MIT License:\n//\n// Copyright (c) 2010-2012, Joe Walnes\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/**\n * This behaves like a WebSocket in every way, except if it fails to connect,\n * or it gets disconnected, it will repeatedly poll until it successfully connects\n * again.\n *\n * It is API compatible, so when you have:\n * ws = new WebSocket('ws://....');\n * you can replace with:\n * ws = new ReconnectingWebSocket('ws://....');\n *\n * The event stream will typically look like:\n * onconnecting\n * onopen\n * onmessage\n * onmessage\n * onclose // lost connection\n * onconnecting\n * onopen // sometime later...\n * onmessage\n * onmessage\n * etc...\n *\n * It is API compatible with the standard WebSocket API, apart from the following members:\n *\n * - `bufferedAmount`\n * - `extensions`\n * - `binaryType`\n *\n * Latest version: https://github.com/joewalnes/reconnecting-websocket/\n * - Joe Walnes\n *\n * Syntax\n * ======\n * var socket = new ReconnectingWebSocket(url, protocols, options);\n *\n * Parameters\n * ==========\n * url - The url you are connecting to.\n * protocols - Optional string or array of protocols.\n * options - See below\n *\n * Options\n * =======\n * Options can either be passed upon instantiation or set after instantiation:\n *\n * var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });\n *\n * or\n *\n * var socket = new ReconnectingWebSocket(url);\n * socket.debug = true;\n * socket.reconnectInterval = 4000;\n *\n * debug\n * - Whether this instance should log debug messages. Accepts true or false. Default: false.\n *\n * automaticOpen\n * - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().\n *\n * reconnectInterval\n * - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.\n *\n * maxReconnectInterval\n * - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.\n *\n * reconnectDecay\n * - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.\n *\n * timeoutInterval\n * - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.\n *\n */\n(function (global, factory) {\n if (typeof define === 'function' && define.amd) {\n define([], factory);\n } else if (typeof module !== 'undefined' && module.exports){\n module.exports = factory();\n } else {\n global.ReconnectingWebSocket = factory();\n }\n})(this, function () {\n\n if (!('WebSocket' in window)) {\n return;\n }\n\n function ReconnectingWebSocket(url, protocols, options) {\n\n // Default settings\n var settings = {\n\n /** Whether this instance should log debug messages. */\n debug: false,\n\n /** Whether or not the websocket should attempt to connect immediately upon instantiation. */\n automaticOpen: true,\n\n /** The number of milliseconds to delay before attempting to reconnect. */\n reconnectInterval: 1000,\n /** The maximum number of milliseconds to delay a reconnection attempt. */\n maxReconnectInterval: 30000,\n /** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */\n reconnectDecay: 1.5,\n\n /** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */\n timeoutInterval: 2000,\n\n /** The maximum number of reconnection attempts to make. Unlimited if null. */\n maxReconnectAttempts: null\n }\n if (!options) { options = {}; }\n\n // Overwrite and define settings with options if they exist.\n for (var key in settings) {\n if (typeof options[key] !== 'undefined') {\n this[key] = options[key];\n } else {\n this[key] = settings[key];\n }\n }\n\n // These should be treated as read-only properties\n\n /** The URL as resolved by the constructor. This is always an absolute URL. Read only. */\n this.url = url;\n\n /** The number of attempted reconnects since starting, or the last successful connection. Read only. */\n this.reconnectAttempts = 0;\n\n /**\n * The current state of the connection.\n * Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED\n * Read only.\n */\n this.readyState = WebSocket.CONNECTING;\n\n /**\n * A string indicating the name of the sub-protocol the server selected; this will be one of\n * the strings specified in the protocols parameter when creating the WebSocket object.\n * Read only.\n */\n this.protocol = null;\n\n // Private state variables\n\n var self = this;\n var ws;\n var forcedClose = false;\n var timedOut = false;\n var eventTarget = document.createElement('div');\n\n // Wire up \"on*\" properties as event handlers\n\n eventTarget.addEventListener('open', function(event) { self.onopen(event); });\n eventTarget.addEventListener('close', function(event) { self.onclose(event); });\n eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });\n eventTarget.addEventListener('message', function(event) { self.onmessage(event); });\n eventTarget.addEventListener('error', function(event) { self.onerror(event); });\n\n // Expose the API required by EventTarget\n\n this.addEventListener = eventTarget.addEventListener.bind(eventTarget);\n this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);\n this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);\n\n /**\n * This function generates an event that is compatible with standard\n * compliant browsers and IE9 - IE11\n *\n * This will prevent the error:\n * Object doesn't support this action\n *\n * http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563\n * @param s String The name that the event should use\n * @param args Object an optional object that the event will use\n */\n function generateEvent(s, args) {\n \tvar evt = document.createEvent(\"CustomEvent\");\n \tevt.initCustomEvent(s, false, false, args);\n \treturn evt;\n };\n\n this.open = function (reconnectAttempt) {\n ws = new WebSocket(self.url, protocols || []);\n\n if (reconnectAttempt) {\n if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {\n return;\n }\n } else {\n eventTarget.dispatchEvent(generateEvent('connecting'));\n this.reconnectAttempts = 0;\n }\n\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);\n }\n\n var localWs = ws;\n var timeout = setTimeout(function() {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);\n }\n timedOut = true;\n localWs.close();\n timedOut = false;\n }, self.timeoutInterval);\n\n ws.onopen = function(event) {\n clearTimeout(timeout);\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onopen', self.url);\n }\n self.protocol = ws.protocol;\n self.readyState = WebSocket.OPEN;\n self.reconnectAttempts = 0;\n var e = generateEvent('open');\n e.isReconnect = reconnectAttempt;\n reconnectAttempt = false;\n eventTarget.dispatchEvent(e);\n };\n\n ws.onclose = function(event) {\n clearTimeout(timeout);\n ws = null;\n if (forcedClose) {\n self.readyState = WebSocket.CLOSED;\n eventTarget.dispatchEvent(generateEvent('close'));\n } else {\n self.readyState = WebSocket.CONNECTING;\n var e = generateEvent('connecting');\n e.code = event.code;\n e.reason = event.reason;\n e.wasClean = event.wasClean;\n eventTarget.dispatchEvent(e);\n if (!reconnectAttempt && !timedOut) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onclose', self.url);\n }\n eventTarget.dispatchEvent(generateEvent('close'));\n }\n\n var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);\n setTimeout(function() {\n self.reconnectAttempts++;\n self.open(true);\n }, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);\n }\n };\n ws.onmessage = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);\n }\n var e = generateEvent('message');\n e.data = event.data;\n eventTarget.dispatchEvent(e);\n };\n ws.onerror = function(event) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'onerror', self.url, event);\n }\n eventTarget.dispatchEvent(generateEvent('error'));\n };\n }\n\n // Whether or not to create a websocket upon instantiation\n if (this.automaticOpen == true) {\n this.open(false);\n }\n\n /**\n * Transmits data to the server over the WebSocket connection.\n *\n * @param data a text string, ArrayBuffer or Blob to send to the server.\n */\n this.send = function(data) {\n if (ws) {\n if (self.debug || ReconnectingWebSocket.debugAll) {\n console.debug('ReconnectingWebSocket', 'send', self.url, data);\n }\n return ws.send(data);\n } else {\n throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';\n }\n };\n\n /**\n * Closes the WebSocket connection or connection attempt, if any.\n * If the connection is already CLOSED, this method does nothing.\n */\n this.close = function(code, reason) {\n // Default CLOSE_NORMAL code\n if (typeof code == 'undefined') {\n code = 1000;\n }\n forcedClose = true;\n if (ws) {\n ws.close(code, reason);\n }\n };\n\n /**\n * Additional public API method to refresh the connection if still open (close, re-open).\n * For example, if the app suspects bad data / missed heart beats, it can try to refresh.\n */\n this.refresh = function() {\n if (ws) {\n ws.close();\n }\n };\n }\n\n /**\n * An event listener to be called when the WebSocket connection's readyState changes to OPEN;\n * this indicates that the connection is ready to send and receive data.\n */\n ReconnectingWebSocket.prototype.onopen = function(event) {};\n /** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */\n ReconnectingWebSocket.prototype.onclose = function(event) {};\n /** An event listener to be called when a connection begins being attempted. */\n ReconnectingWebSocket.prototype.onconnecting = function(event) {};\n /** An event listener to be called when a message is received from the server. */\n ReconnectingWebSocket.prototype.onmessage = function(event) {};\n /** An event listener to be called when an error occurs. */\n ReconnectingWebSocket.prototype.onerror = function(event) {};\n\n /**\n * Whether all instances of ReconnectingWebSocket should log debug messages.\n * Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.\n */\n ReconnectingWebSocket.debugAll = false;\n\n ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;\n ReconnectingWebSocket.OPEN = WebSocket.OPEN;\n ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;\n ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;\n\n return ReconnectingWebSocket;\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./~/reconnectingwebsocket/reconnecting-websocket.js\n// module id = 1\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 48727d0..2979147 100644 --- a/src/index.js +++ b/src/index.js @@ -1,10 +1,11 @@ const WebSocket = require('ws'); export default class CertStreamClient{ - constructor(callback, skipHeartbeats = false) { + constructor(callback, skipHeartbeats = false, pingSeconds = 10) { this.context = {}; this.callback = callback; this.skipHeartbeats = skipHeartbeats; + this.pingSeconds = pingSeconds; } connect(url="wss://certstream.calidog.io/"){ @@ -13,6 +14,8 @@ export default class CertStreamClient{ this.ws.on('open', () => { console.log("Connection established to certstream! Waiting for messages..."); + + this.pingInterval = setInterval(this.ws.ping.bind(this.ws), this.pingSeconds * 1000); }); this.ws.on('message', (message) => { @@ -24,5 +27,9 @@ export default class CertStreamClient{ this.callback(parsedMessage, this.context); }); + + this.ws.on('close', () => { + clearInterval(this.pingInterval); + }); } };