Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

home-assistant-js-websocket

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

home-assistant-js-websocket - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

284

dist/haws.cjs.js

@@ -1,1 +0,283 @@

"use strict";function auth(e){return{type:"auth",api_password:e}}function states(){return{type:"get_states"}}function config(){return{type:"get_config"}}function services(){return{type:"get_services"}}function panels(){return{type:"get_panels"}}function callService$1(e,n,t){var s={type:"call_service",domain:e,service:n};return t&&(s.service_data=t),s}function subscribeEvents$1(e){var n={type:"subscribe_events"};return e&&(n.event_type=e),n}function unsubscribeEvents(e){return{type:"unsubscribe_events",subscription:e}}function extractResult(e){return e.result}function createConnection(e,n){var t=new Connection(e,n);return t.connect()}Object.defineProperty(exports,"__esModule",{value:!0});var ERR_CANNOT_CONNECT=1,ERR_INVALID_AUTH=2,Connection=function(e,n){this.url=e,this.options=n||{},this.commandId=1,this.commands={},this.connectionTries=0,this.eventListeners={}};Connection.prototype.addEventListener=function(e,n){var t=this.eventListeners[e];t||(t=this.eventListeners[e]=[]),t.push(n)},Connection.prototype.fireEvent=function(e){var n=this;(this.eventListeners[e]||[]).forEach(function(e){return e(n)})},Connection.prototype.connect=function(){var e=this;return new Promise(function(n,t){var s=e.commands;Object.keys(s).forEach(function(e){var n=s[e];n.reject&&n.reject()});var o=!1;e.connectionTries+=1,e.socket=new WebSocket(e.url),e.socket.addEventListener("open",function(){e.connectionTries=0}),e.socket.addEventListener("message",function(r){var i=JSON.parse(r.data);switch(i.type){case"auth_required":e.sendMessage(auth(e.options.authToken));break;case"auth_invalid":t({code:ERR_INVALID_AUTH}),o=!0;break;case"auth_ok":n(e),e.fireEvent("ready"),e.commandId=1,e.commands={},Object.keys(s).forEach(function(n){var t=s[n];t.eventType&&e.subscribeEvents(t.eventCallback,t.eventType).then(function(e){t.unsubscribe=e})});break;case"event":e.commands[i.id].eventCallback(i.event);break;case"result":i.success?e.commands[i.id].resolve(i):e.commands[i.id].reject(i.error),delete e.commands[i.id]}}),e.socket.addEventListener("close",function(){if(!o){0===e.connectionTries?e.fireEvent("disconnected"):t(ERR_CANNOT_CONNECT);var n=1e3*Math.min(e.connectionTries,5);setTimeout(function(){return e.connect()},n)}})})},Connection.prototype.getStates=function(){return this.sendMessagePromise(states()).then(extractResult)},Connection.prototype.getServices=function(){return this.sendMessagePromise(services()).then(extractResult)},Connection.prototype.getPanels=function(){return this.sendMessagePromise(panels()).then(extractResult)},Connection.prototype.getConfig=function(){return this.sendMessagePromise(config()).then(extractResult)},Connection.prototype.callService=function(e,n,t){return this.sendMessagePromise(callService$1(e,n,t))},Connection.prototype.subscribeEvents=function(e,n){var t=this;return this.sendMessagePromise(subscribeEvents$1(n)).then(function(s){var o={eventCallback:e,eventType:n,unsubscribe:function(){return t.sendMessagePromise(unsubscribeEvents(s.id)).then(function(){delete t.commands[s.id]})}};return t.commands[s.id]=o,function(){return o.unsubscribe()}})},Connection.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},Connection.prototype.sendMessagePromise=function(e){var n=this;return new Promise(function(t,s){n.commandId+=1;var o=n.commandId;e.id=o,n.commands[o]={resolve:t,reject:s},n.sendMessage(e)})},exports.ERR_CANNOT_CONNECT=ERR_CANNOT_CONNECT,exports.ERR_INVALID_AUTH=ERR_INVALID_AUTH,exports.createConnection=createConnection,exports.default=createConnection;
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function auth(authToken) {
return {
type: 'auth',
api_password: authToken,
};
}
function states() {
return {
type: 'get_states',
};
}
function config() {
return {
type: 'get_config',
};
}
function services() {
return {
type: 'get_services',
};
}
function panels() {
return {
type: 'get_panels',
};
}
function callService$1(domain, service, serviceData) {
var message = {
type: 'call_service',
domain: domain,
service: service,
};
if (serviceData) {
message.service_data = serviceData;
}
return message;
}
function subscribeEvents$1(eventType) {
var message = {
type: 'subscribe_events',
};
if (eventType) {
message.event_type = eventType;
}
return message;
}
function unsubscribeEvents(subscription) {
return {
type: 'unsubscribe_events',
subscription: subscription,
};
}
var ERR_CANNOT_CONNECT = 1;
var ERR_INVALID_AUTH = 2;
function extractResult(message) {
return message.result;
}
var Connection = function Connection(url, options) {
this.url = url;
this.options = options || {};
this.commandId = 1;
this.commands = {};
this.connectionTries = 0;
this.eventListeners = {};
this.closeRequested = false;
};
Connection.prototype.addEventListener = function addEventListener (eventType, callback) {
var listeners = this.eventListeners[eventType];
if (!listeners) {
listeners = this.eventListeners[eventType] = [];
}
listeners.push(callback);
};
Connection.prototype.fireEvent = function fireEvent (eventType) {
var this$1 = this;
(this.eventListeners[eventType] || []).forEach(function (callback) { return callback(this$1); });
};
Connection.prototype.connect = function connect () {
var this$1 = this;
return new Promise(function (resolve, reject) {
// Used for resubscribing in the future
var oldCommands = this$1.commands;
Object.keys(oldCommands).forEach(function (id) {
var info = oldCommands[id];
// Reject stuff still waiting for an answer
if (info.reject) {
info.reject();
}
});
// If invalid auth, we will not try to reconnect.
var invalidAuth = false;
this$1.connectionTries += 1;
this$1.socket = new WebSocket(this$1.url);
this$1.socket.addEventListener('open', function () {
this$1.connectionTries = 0;
});
this$1.socket.addEventListener('message', function (event) {
var message = JSON.parse(event.data);
{
/* eslint-disable no-console */
console.log(message);
/* eslint-enable no-console */
}
switch (message.type) {
case 'auth_required':
this$1.sendMessage(auth(this$1.options.authToken));
break;
case 'auth_invalid':
reject({ code: ERR_INVALID_AUTH });
invalidAuth = true;
break;
case 'auth_ok':
resolve(this$1);
this$1.fireEvent('ready');
// Re-subscribe to events and update old location of unsub method
// so old unsub method keeps working.
this$1.commandId = 1;
this$1.commands = {};
Object.keys(oldCommands).forEach(function (id) {
var info = oldCommands[id];
if (info.eventType) {
this$1.subscribeEvents(info.eventCallback, info.eventType)
.then(function (unsub) { info.unsubscribe = unsub; });
}
});
break;
case 'event':
this$1.commands[message.id].eventCallback(message.event);
break;
case 'result':
if (message.success) {
this$1.commands[message.id].resolve(message);
} else {
this$1.commands[message.id].reject(message.error);
}
delete this$1.commands[message.id];
break;
default:
{
/* eslint-disable no-console */
console.warn('Unhandled message', message);
/* eslint-enable no-console */
}
}
});
this$1.socket.addEventListener('close', function () {
if (invalidAuth || this$1.closeRequested) {
// When we have invalid auth, let's not reconnect or we get banned.
return;
} else if (this$1.connectionTries === 0) {
// We were connected at some point.
this$1.fireEvent('disconnected');
} else {
// We never were connected
reject(ERR_CANNOT_CONNECT);
}
// Try again
var waitTime = Math.min(this$1.connectionTries, 5) * 1000;
setTimeout(function () { return this$1.connect(); }, waitTime);
});
});
};
Connection.prototype.close = function close () {
this.closeRequested = true;
this.socket.close();
};
Connection.prototype.getStates = function getStates () {
return this.sendMessagePromise(states()).then(extractResult);
};
Connection.prototype.getServices = function getServices () {
return this.sendMessagePromise(services()).then(extractResult);
};
Connection.prototype.getPanels = function getPanels () {
return this.sendMessagePromise(panels()).then(extractResult);
};
Connection.prototype.getConfig = function getConfig () {
return this.sendMessagePromise(config()).then(extractResult);
};
Connection.prototype.callService = function callService (domain, service, serviceData) {
return this.sendMessagePromise(callService$1(domain, service, serviceData));
};
// eventCallback will be called when a new event fires
// Returned promise resolves to an unsubscribe function.
Connection.prototype.subscribeEvents = function subscribeEvents (eventCallback, eventType) {
var this$1 = this;
return this.sendMessagePromise(subscribeEvents$1(eventType)).then(
function (resultMessage) {
// We store unsubscribe on info object. That way we can overwrite it in case
// we get disconnected and we have to subscribe again.
var info = {
eventCallback: eventCallback,
eventType: eventType,
unsubscribe: function () { return this$1.sendMessagePromise(unsubscribeEvents(resultMessage.id))
.then(function () { delete this$1.commands[resultMessage.id]; }); },
};
this$1.commands[resultMessage.id] = info;
return function () { return info.unsubscribe(); };
/* eslint-disable comma-dangle */ /* comma crashes Buble */
}
/* eslint-enable comma-dangle */
);
};
Connection.prototype.sendMessage = function sendMessage (message) {
this.socket.send(JSON.stringify(message));
};
Connection.prototype.sendMessagePromise = function sendMessagePromise (message) {
var this$1 = this;
return new Promise(function (resolve, reject) {
this$1.commandId += 1;
var commandId = this$1.commandId;
/* eslint-disable no-param-reassign */
message.id = commandId;
/* eslint-enable no-param-reassign */
this$1.commands[commandId] = { resolve: resolve, reject: reject };
this$1.sendMessage(message);
});
};
function createConnection(url, options) {
var conn = new Connection(url, options);
return conn.connect();
}
exports.ERR_CANNOT_CONNECT = ERR_CANNOT_CONNECT;
exports.ERR_INVALID_AUTH = ERR_INVALID_AUTH;
exports.createConnection = createConnection;
exports['default'] = createConnection;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjpudWxsLCJzb3VyY2VzIjpbIi4uL2xpYi9tZXNzYWdlcy5qcyIsIi4uL2xpYi9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gYXV0aChhdXRoVG9rZW4pIHtcbiAgcmV0dXJuIHtcbiAgICB0eXBlOiAnYXV0aCcsXG4gICAgYXBpX3Bhc3N3b3JkOiBhdXRoVG9rZW4sXG4gIH07XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBzdGF0ZXMoKSB7XG4gIHJldHVybiB7XG4gICAgdHlwZTogJ2dldF9zdGF0ZXMnLFxuICB9O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gY29uZmlnKCkge1xuICByZXR1cm4ge1xuICAgIHR5cGU6ICdnZXRfY29uZmlnJyxcbiAgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHNlcnZpY2VzKCkge1xuICByZXR1cm4ge1xuICAgIHR5cGU6ICdnZXRfc2VydmljZXMnLFxuICB9O1xufVxuXG5leHBvcnQgZnVuY3Rpb24gcGFuZWxzKCkge1xuICByZXR1cm4ge1xuICAgIHR5cGU6ICdnZXRfcGFuZWxzJyxcbiAgfTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGNhbGxTZXJ2aWNlKGRvbWFpbiwgc2VydmljZSwgc2Vyd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AgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlICdhdXRoX29rJzpcbiAgICAgICAgICAgIHJlc29sdmUodGhpcyk7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgncmVhZHknKTtcblxuICAgICAgICAgICAgLy8gUmUtc3Vic2NyaWJlIHRvIGV2ZW50cyBhbmQgdXBkYXRlIG9sZCBsb2NhdGlvbiBvZiB1bnN1YiBtZXRob2RcbiAgICAgICAgICAgIC8vIHNvIG9sZCB1bnN1YiBtZXRob2Qga2VlcHMgd29ya2luZy5cbiAgICAgICAgICAgIHRoaXMuY29tbWFuZElkID0gMTtcbiAgICAgICAgICAgIHRoaXMuY29tbWFuZHMgPSB7fTtcblxuICAgICAgICAgICAgT2JqZWN0LmtleXMob2xkQ29tbWFuZHMpLmZvckVhY2goKGlkKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IGluZm8gPSBvbGRDb21tYW5kc1tpZF07XG5cbiAgICAgICAgICAgICAgaWYgKGluZm8uZXZlbnRUeXBlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zdWJzY3JpYmVFdmVudHMoaW5mby5ldmVudENhbGxiYWNrLCBpbmZvLmV2ZW50VHlwZSlcbiAgICAgICAgICAgICAgICAgIC50aGVuKCh1bnN1YikgPT4geyBpbmZvLnVuc3Vic2NyaWJlID0gdW5zdWI7IH0pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgY2FzZSAnZXZlbnQnOlxuICAgICAgICAgICAgdGhpcy5jb21tYW5kc1ttZXNzYWdlLmlkXS5ldmVudENhbGxiYWNrKG1lc3NhZ2UuZXZlbnQpO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlICdyZXN1bHQnOlxuICAgICAgICAgICAgaWYgKG1lc3NhZ2Uuc3VjY2Vzcykge1xuICAgICAgICAgICAgICB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdLnJlc29sdmUobWVzc2FnZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdLnJlamVjdChtZXNzYWdlLmVycm9yKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgaWYgKF9fREVWX18pIHtcbiAgICAgICAgICAgICAgLyogZXNsaW50LWRpc2FibGUgbm8tY29uc29sZSAqL1xuICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ1VuaGFuZGxlZCBtZXNzYWdlJywgbWVzc2FnZSk7XG4gICAgICAgICAgICAgIC8qIGVzbGludC1lbmFibGUgbm8tY29uc29sZSAqL1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9KTtcblxuICAgICAgdGhpcy5zb2NrZXQuYWRkRXZlbnRMaXN0ZW5lcignY2xvc2UnLCAoKSA9PiB7XG4gICAgICAgIGlmIChpbnZhbGlkQXV0aCB8fCB0aGlzLmNsb3NlUmVxdWVzdGVkKSB7XG4gICAgICAgICAgLy8gV2hlbiB3ZSBoYXZlIGludmFsaWQgYXV0aCwgbGV0J3Mgbm90IHJlY29ubmVjdCBvciB3ZSBnZXQgYmFubmVkLlxuICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLmNvbm5lY3Rpb25UcmllcyA9PT0gMCkge1xuICAgICAgICAgIC8vIFdlIHdlcmUgY29ubmVjdGVkIGF0IHNvbWUgcG9pbnQuXG4gICAgICAgICAgdGhpcy5maXJlRXZlbnQoJ2Rpc2Nvbm5lY3RlZCcpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIC8vIFdlIG5ldmVyIHdlcmUgY29ubmVjdGVkXG4gICAgICAgICA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DQUN2QixBQUVELEFBQWdDOzs7OzsifQ==

@@ -1,1 +0,276 @@

function auth(e){return{type:"auth",api_password:e}}function states(){return{type:"get_states"}}function config(){return{type:"get_config"}}function services(){return{type:"get_services"}}function panels(){return{type:"get_panels"}}function callService$1(e,n,t){var s={type:"call_service",domain:e,service:n};return t&&(s.service_data=t),s}function subscribeEvents$1(e){var n={type:"subscribe_events"};return e&&(n.event_type=e),n}function unsubscribeEvents(e){return{type:"unsubscribe_events",subscription:e}}function extractResult(e){return e.result}function createConnection(e,n){var t=new Connection(e,n);return t.connect()}var ERR_CANNOT_CONNECT=1,ERR_INVALID_AUTH=2,Connection=function(e,n){this.url=e,this.options=n||{},this.commandId=1,this.commands={},this.connectionTries=0,this.eventListeners={}};Connection.prototype.addEventListener=function(e,n){var t=this.eventListeners[e];t||(t=this.eventListeners[e]=[]),t.push(n)},Connection.prototype.fireEvent=function(e){var n=this;(this.eventListeners[e]||[]).forEach(function(e){return e(n)})},Connection.prototype.connect=function(){var e=this;return new Promise(function(n,t){var s=e.commands;Object.keys(s).forEach(function(e){var n=s[e];n.reject&&n.reject()});var o=!1;e.connectionTries+=1,e.socket=new WebSocket(e.url),e.socket.addEventListener("open",function(){e.connectionTries=0}),e.socket.addEventListener("message",function(r){var i=JSON.parse(r.data);switch(i.type){case"auth_required":e.sendMessage(auth(e.options.authToken));break;case"auth_invalid":t({code:ERR_INVALID_AUTH}),o=!0;break;case"auth_ok":n(e),e.fireEvent("ready"),e.commandId=1,e.commands={},Object.keys(s).forEach(function(n){var t=s[n];t.eventType&&e.subscribeEvents(t.eventCallback,t.eventType).then(function(e){t.unsubscribe=e})});break;case"event":e.commands[i.id].eventCallback(i.event);break;case"result":i.success?e.commands[i.id].resolve(i):e.commands[i.id].reject(i.error),delete e.commands[i.id]}}),e.socket.addEventListener("close",function(){if(!o){0===e.connectionTries?e.fireEvent("disconnected"):t(ERR_CANNOT_CONNECT);var n=1e3*Math.min(e.connectionTries,5);setTimeout(function(){return e.connect()},n)}})})},Connection.prototype.getStates=function(){return this.sendMessagePromise(states()).then(extractResult)},Connection.prototype.getServices=function(){return this.sendMessagePromise(services()).then(extractResult)},Connection.prototype.getPanels=function(){return this.sendMessagePromise(panels()).then(extractResult)},Connection.prototype.getConfig=function(){return this.sendMessagePromise(config()).then(extractResult)},Connection.prototype.callService=function(e,n,t){return this.sendMessagePromise(callService$1(e,n,t))},Connection.prototype.subscribeEvents=function(e,n){var t=this;return this.sendMessagePromise(subscribeEvents$1(n)).then(function(s){var o={eventCallback:e,eventType:n,unsubscribe:function(){return t.sendMessagePromise(unsubscribeEvents(s.id)).then(function(){delete t.commands[s.id]})}};return t.commands[s.id]=o,function(){return o.unsubscribe()}})},Connection.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},Connection.prototype.sendMessagePromise=function(e){var n=this;return new Promise(function(t,s){n.commandId+=1;var o=n.commandId;e.id=o,n.commands[o]={resolve:t,reject:s},n.sendMessage(e)})};export{ERR_CANNOT_CONNECT:ERR_CANNOT_CONNECT,ERR_INVALID_AUTH:ERR_INVALID_AUTH,createConnection:createConnection};export default createConnection;
function auth(authToken) {
return {
type: 'auth',
api_password: authToken,
};
}
function states() {
return {
type: 'get_states',
};
}
function config() {
return {
type: 'get_config',
};
}
function services() {
return {
type: 'get_services',
};
}
function panels() {
return {
type: 'get_panels',
};
}
function callService$1(domain, service, serviceData) {
var message = {
type: 'call_service',
domain: domain,
service: service,
};
if (serviceData) {
message.service_data = serviceData;
}
return message;
}
function subscribeEvents$1(eventType) {
var message = {
type: 'subscribe_events',
};
if (eventType) {
message.event_type = eventType;
}
return message;
}
function unsubscribeEvents(subscription) {
return {
type: 'unsubscribe_events',
subscription: subscription,
};
}
var ERR_CANNOT_CONNECT = 1;
var ERR_INVALID_AUTH = 2;
function extractResult(message) {
return message.result;
}
var Connection = function Connection(url, options) {
this.url = url;
this.options = options || {};
this.commandId = 1;
this.commands = {};
this.connectionTries = 0;
this.eventListeners = {};
this.closeRequested = false;
};
Connection.prototype.addEventListener = function addEventListener (eventType, callback) {
var listeners = this.eventListeners[eventType];
if (!listeners) {
listeners = this.eventListeners[eventType] = [];
}
listeners.push(callback);
};
Connection.prototype.fireEvent = function fireEvent (eventType) {
var this$1 = this;
(this.eventListeners[eventType] || []).forEach(function (callback) { return callback(this$1); });
};
Connection.prototype.connect = function connect () {
var this$1 = this;
return new Promise(function (resolve, reject) {
// Used for resubscribing in the future
var oldCommands = this$1.commands;
Object.keys(oldCommands).forEach(function (id) {
var info = oldCommands[id];
// Reject stuff still waiting for an answer
if (info.reject) {
info.reject();
}
});
// If invalid auth, we will not try to reconnect.
var invalidAuth = false;
this$1.connectionTries += 1;
this$1.socket = new WebSocket(this$1.url);
this$1.socket.addEventListener('open', function () {
this$1.connectionTries = 0;
});
this$1.socket.addEventListener('message', function (event) {
var message = JSON.parse(event.data);
{
/* eslint-disable no-console */
console.log(message);
/* eslint-enable no-console */
}
switch (message.type) {
case 'auth_required':
this$1.sendMessage(auth(this$1.options.authToken));
break;
case 'auth_invalid':
reject({ code: ERR_INVALID_AUTH });
invalidAuth = true;
break;
case 'auth_ok':
resolve(this$1);
this$1.fireEvent('ready');
// Re-subscribe to events and update old location of unsub method
// so old unsub method keeps working.
this$1.commandId = 1;
this$1.commands = {};
Object.keys(oldCommands).forEach(function (id) {
var info = oldCommands[id];
if (info.eventType) {
this$1.subscribeEvents(info.eventCallback, info.eventType)
.then(function (unsub) { info.unsubscribe = unsub; });
}
});
break;
case 'event':
this$1.commands[message.id].eventCallback(message.event);
break;
case 'result':
if (message.success) {
this$1.commands[message.id].resolve(message);
} else {
this$1.commands[message.id].reject(message.error);
}
delete this$1.commands[message.id];
break;
default:
{
/* eslint-disable no-console */
console.warn('Unhandled message', message);
/* eslint-enable no-console */
}
}
});
this$1.socket.addEventListener('close', function () {
if (invalidAuth || this$1.closeRequested) {
// When we have invalid auth, let's not reconnect or we get banned.
return;
} else if (this$1.connectionTries === 0) {
// We were connected at some point.
this$1.fireEvent('disconnected');
} else {
// We never were connected
reject(ERR_CANNOT_CONNECT);
}
// Try again
var waitTime = Math.min(this$1.connectionTries, 5) * 1000;
setTimeout(function () { return this$1.connect(); }, waitTime);
});
});
};
Connection.prototype.close = function close () {
this.closeRequested = true;
this.socket.close();
};
Connection.prototype.getStates = function getStates () {
return this.sendMessagePromise(states()).then(extractResult);
};
Connection.prototype.getServices = function getServices () {
return this.sendMessagePromise(services()).then(extractResult);
};
Connection.prototype.getPanels = function getPanels () {
return this.sendMessagePromise(panels()).then(extractResult);
};
Connection.prototype.getConfig = function getConfig () {
return this.sendMessagePromise(config()).then(extractResult);
};
Connection.prototype.callService = function callService (domain, service, serviceData) {
return this.sendMessagePromise(callService$1(domain, service, serviceData));
};
// eventCallback will be called when a new event fires
// Returned promise resolves to an unsubscribe function.
Connection.prototype.subscribeEvents = function subscribeEvents (eventCallback, eventType) {
var this$1 = this;
return this.sendMessagePromise(subscribeEvents$1(eventType)).then(
function (resultMessage) {
// We store unsubscribe on info object. That way we can overwrite it in case
// we get disconnected and we have to subscribe again.
var info = {
eventCallback: eventCallback,
eventType: eventType,
unsubscribe: function () { return this$1.sendMessagePromise(unsubscribeEvents(resultMessage.id))
.then(function () { delete this$1.commands[resultMessage.id]; }); },
};
this$1.commands[resultMessage.id] = info;
return function () { return info.unsubscribe(); };
/* eslint-disable comma-dangle */ /* comma crashes Buble */
}
/* eslint-enable comma-dangle */
);
};
Connection.prototype.sendMessage = function sendMessage (message) {
this.socket.send(JSON.stringify(message));
};
Connection.prototype.sendMessagePromise = function sendMessagePromise (message) {
var this$1 = this;
return new Promise(function (resolve, reject) {
this$1.commandId += 1;
var commandId = this$1.commandId;
/* eslint-disable no-param-reassign */
message.id = commandId;
/* eslint-enable no-param-reassign */
this$1.commands[commandId] = { resolve: resolve, reject: reject };
this$1.sendMessage(message);
});
};
function createConnection(url, options) {
var conn = new Connection(url, options);
return conn.connect();
}
export { ERR_CANNOT_CONNECT, ERR_INVALID_AUTH, createConnection };export default createConnection;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ZXIoJ29wZW4nLCAoKSA9PiB7XG4gICAgICAgIHRoaXMuY29ubmVjdGlvblRyaWVzID0gMDtcbiAgICAgIH0pO1xuXG4gICAgICB0aGlzLnNvY2tldC5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgKGV2ZW50KSA9PiB7XG4gICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBKU09OLnBhcnNlKGV2ZW50LmRhdGEpO1xuXG4gICAgICAgIGlmIChfX0RFVl9fKSB7XG4gICAgICAgICAgLyogZXNsaW50LWRpc2FibGUgbm8tY29uc29sZSAqL1xuICAgICAgICAgIGNvbnNvbGUubG9nKG1lc3NhZ2UpO1xuICAgICAgICAgIC8qIGVzbGludC1lbmFibGUgbm8tY29uc29sZSAqL1xuICAgICAgICB9XG5cbiAgICAgICAgc3dpdGNoIChtZXNzYWdlLnR5cGUpIHtcbiAgICAgICAgICBjYXNlICdhdXRoX3JlcXVpcmVkJzpcbiAgICAgICAgICAgIHRoaXMuc2VuZE1lc3NhZ2UobWVzc2FnZXMuYXV0aCh0aGlzLm9wdGlvbnMuYXV0aFRva2VuKSk7XG4gICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgIGNhc2UgJ2F1dGhfaW52YWxpZCc6XG4gICAgICAgICAgICByZWplY3QoeyBjb2RlOiBFUlJfSU5WQUxJRF9BVVRIIH0pO1xuICAgICAgICAgICAgaW52YWxpZEF1dGggPSB0cnVlO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlICdhdXRoX29rJzpcbiAgICAgICAgICAgIHJlc29sdmUodGhpcyk7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgncmVhZHknKTtcblxuICAgICAgICAgICAgLy8gUmUtc3Vic2NyaWJlIHRvIGV2ZW50cyBhbmQgdXBkYXRlIG9sZCBsb2NhdGlvbiBvZiB1bnN1YiBtZXRob2RcbiAgICAgICAgICAgIC8vIHNvIG9sZCB1bnN1YiBtZXRob2Qga2VlcHMgd29ya2luZy5cbiAgICAgICAgICAgIHRoaXMuY29tbWFuZElkID0gMTtcbiAgICAgICAgICAgIHRoaXMuY29tbWFuZHMgPSB7fTtcblxuICAgICAgICAgICAgT2JqZWN0LmtleXMob2xkQ29tbWFuZHMpLmZvckVhY2goKGlkKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IGluZm8gPSBvbGRDb21tYW5kc1tpZF07XG5cbiAgICAgICAgICAgICAgaWYgKGluZm8uZXZlbnRUeXBlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zdWJzY3JpYmVFdmVudHMoaW5mby5ldmVudENhbGxiYWNrLCBpbmZvLmV2ZW50VHlwZSlcbiAgICAgICAgICAgICAgICAgIC50aGVuKCh1bnN1YikgPT4geyBpbmZvLnVuc3Vic2NyaWJlID0gdW5zdWI7IH0pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgY2FzZSAnZXZlbnQnOlxuICAgICAgICAgICAgdGhpcy5jb21tYW5kc1ttZXNzYWdlLmlkXS5ldmVudENhbGxiYWNrKG1lc3NhZ2UuZXZlbnQpO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlICdyZXN1bHQnOlxuICAgICAgICAgICAgaWYgKG1lc3NhZ2Uuc3VjY2Vzcykge1xuICAgICAgICAgICAgICB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdLnJlc29sdmUobWVzc2FnZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdLnJlamVjdChtZXNzYWdlLmVycm9yKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgaWYgK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UFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztDQUMzQyxDQUFBOztBQUVILHFCQUFFLGtCQUFrQixnQ0FBQyxPQUFPLEVBQUU7OztFQUM1QixPQUFTLElBQUksT0FBTyxDQUFDLFVBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRTtJQUNyQyxNQUFNLENBQUMsU0FBUyxJQUFJLENBQUMsQ0FBQztJQUN0QixJQUFRLFNBQVMsR0FBR0EsTUFBSSxDQUFDLFNBQVMsQ0FBQzs7SUFFbkMsT0FBUyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUM7O0lBRXpCLE1BQU0sQ0FBQyxRQUFRLENBQUMsU0FBUyxDQUFDLEdBQUcsRUFBRSxTQUFBLE9BQU8sRUFBRSxRQUFBLE1BQU0sRUFBRSxDQUFDO0lBQ2pELE1BQU0sQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLENBQUM7R0FDM0IsQ0FBQyxDQUFDO0NBQ0osQ0FBQTs7QUFHSCxBQUFPLFNBQVMsZ0JBQWdCLENBQUMsR0FBRyxFQUFFLE9BQU8sRUFBRTtFQUM3Q0YsSUFBTSxJQUFJLEdBQUcsSUFBSSxVQUFVLENBQUMsR0FBRyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0VBQzFDLE9BQU8sSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0NBQ3ZCLEFBRUQsQUFBZ0M7OyJ9

@@ -1,1 +0,289 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.HAWS=e.HAWS||{})}(this,function(e){"use strict";function t(e){return{type:"auth",api_password:e}}function n(){return{type:"get_states"}}function s(){return{type:"get_config"}}function r(){return{type:"get_services"}}function o(){return{type:"get_panels"}}function i(e,t,n){var s={type:"call_service",domain:e,service:t};return n&&(s.service_data=n),s}function c(e){var t={type:"subscribe_events"};return e&&(t.event_type=e),t}function u(e){return{type:"unsubscribe_events",subscription:e}}function a(e){return e.result}function d(e,t){var n=new v(e,t);return n.connect()}var f=1,p=2,v=function(e,t){this.url=e,this.options=t||{},this.commandId=1,this.commands={},this.connectionTries=0,this.eventListeners={}};v.prototype.addEventListener=function(e,t){var n=this.eventListeners[e];n||(n=this.eventListeners[e]=[]),n.push(t)},v.prototype.fireEvent=function(e){var t=this;(this.eventListeners[e]||[]).forEach(function(e){return e(t)})},v.prototype.connect=function(){var e=this;return new Promise(function(n,s){var r=e.commands;Object.keys(r).forEach(function(e){var t=r[e];t.reject&&t.reject()});var o=!1;e.connectionTries+=1,e.socket=new WebSocket(e.url),e.socket.addEventListener("open",function(){e.connectionTries=0}),e.socket.addEventListener("message",function(i){var c=JSON.parse(i.data);switch(c.type){case"auth_required":e.sendMessage(t(e.options.authToken));break;case"auth_invalid":s({code:p}),o=!0;break;case"auth_ok":n(e),e.fireEvent("ready"),e.commandId=1,e.commands={},Object.keys(r).forEach(function(t){var n=r[t];n.eventType&&e.subscribeEvents(n.eventCallback,n.eventType).then(function(e){n.unsubscribe=e})});break;case"event":e.commands[c.id].eventCallback(c.event);break;case"result":c.success?e.commands[c.id].resolve(c):e.commands[c.id].reject(c.error),delete e.commands[c.id]}}),e.socket.addEventListener("close",function(){if(!o){0===e.connectionTries?e.fireEvent("disconnected"):s(f);var t=1e3*Math.min(e.connectionTries,5);setTimeout(function(){return e.connect()},t)}})})},v.prototype.getStates=function(){return this.sendMessagePromise(n()).then(a)},v.prototype.getServices=function(){return this.sendMessagePromise(r()).then(a)},v.prototype.getPanels=function(){return this.sendMessagePromise(o()).then(a)},v.prototype.getConfig=function(){return this.sendMessagePromise(s()).then(a)},v.prototype.callService=function(e,t,n){return this.sendMessagePromise(i(e,t,n))},v.prototype.subscribeEvents=function(e,t){var n=this;return this.sendMessagePromise(c(t)).then(function(s){var r={eventCallback:e,eventType:t,unsubscribe:function(){return n.sendMessagePromise(u(s.id)).then(function(){delete n.commands[s.id]})}};return n.commands[s.id]=r,function(){return r.unsubscribe()}})},v.prototype.sendMessage=function(e){this.socket.send(JSON.stringify(e))},v.prototype.sendMessagePromise=function(e){var t=this;return new Promise(function(n,s){t.commandId+=1;var r=t.commandId;e.id=r,t.commands[r]={resolve:n,reject:s},t.sendMessage(e)})},e.ERR_CANNOT_CONNECT=f,e.ERR_INVALID_AUTH=p,e.createConnection=d,e.default=d,Object.defineProperty(e,"__esModule",{value:!0})});
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.HAWS = global.HAWS || {})));
}(this, (function (exports) { 'use strict';
function auth(authToken) {
return {
type: 'auth',
api_password: authToken,
};
}
function states() {
return {
type: 'get_states',
};
}
function config() {
return {
type: 'get_config',
};
}
function services() {
return {
type: 'get_services',
};
}
function panels() {
return {
type: 'get_panels',
};
}
function callService$1(domain, service, serviceData) {
var message = {
type: 'call_service',
domain: domain,
service: service,
};
if (serviceData) {
message.service_data = serviceData;
}
return message;
}
function subscribeEvents$1(eventType) {
var message = {
type: 'subscribe_events',
};
if (eventType) {
message.event_type = eventType;
}
return message;
}
function unsubscribeEvents(subscription) {
return {
type: 'unsubscribe_events',
subscription: subscription,
};
}
var ERR_CANNOT_CONNECT = 1;
var ERR_INVALID_AUTH = 2;
function extractResult(message) {
return message.result;
}
var Connection = function Connection(url, options) {
this.url = url;
this.options = options || {};
this.commandId = 1;
this.commands = {};
this.connectionTries = 0;
this.eventListeners = {};
this.closeRequested = false;
};
Connection.prototype.addEventListener = function addEventListener (eventType, callback) {
var listeners = this.eventListeners[eventType];
if (!listeners) {
listeners = this.eventListeners[eventType] = [];
}
listeners.push(callback);
};
Connection.prototype.fireEvent = function fireEvent (eventType) {
var this$1 = this;
(this.eventListeners[eventType] || []).forEach(function (callback) { return callback(this$1); });
};
Connection.prototype.connect = function connect () {
var this$1 = this;
return new Promise(function (resolve, reject) {
// Used for resubscribing in the future
var oldCommands = this$1.commands;
Object.keys(oldCommands).forEach(function (id) {
var info = oldCommands[id];
// Reject stuff still waiting for an answer
if (info.reject) {
info.reject();
}
});
// If invalid auth, we will not try to reconnect.
var invalidAuth = false;
this$1.connectionTries += 1;
this$1.socket = new WebSocket(this$1.url);
this$1.socket.addEventListener('open', function () {
this$1.connectionTries = 0;
});
this$1.socket.addEventListener('message', function (event) {
var message = JSON.parse(event.data);
{
/* eslint-disable no-console */
console.log(message);
/* eslint-enable no-console */
}
switch (message.type) {
case 'auth_required':
this$1.sendMessage(auth(this$1.options.authToken));
break;
case 'auth_invalid':
reject({ code: ERR_INVALID_AUTH });
invalidAuth = true;
break;
case 'auth_ok':
resolve(this$1);
this$1.fireEvent('ready');
// Re-subscribe to events and update old location of unsub method
// so old unsub method keeps working.
this$1.commandId = 1;
this$1.commands = {};
Object.keys(oldCommands).forEach(function (id) {
var info = oldCommands[id];
if (info.eventType) {
this$1.subscribeEvents(info.eventCallback, info.eventType)
.then(function (unsub) { info.unsubscribe = unsub; });
}
});
break;
case 'event':
this$1.commands[message.id].eventCallback(message.event);
break;
case 'result':
if (message.success) {
this$1.commands[message.id].resolve(message);
} else {
this$1.commands[message.id].reject(message.error);
}
delete this$1.commands[message.id];
break;
default:
{
/* eslint-disable no-console */
console.warn('Unhandled message', message);
/* eslint-enable no-console */
}
}
});
this$1.socket.addEventListener('close', function () {
if (invalidAuth || this$1.closeRequested) {
// When we have invalid auth, let's not reconnect or we get banned.
return;
} else if (this$1.connectionTries === 0) {
// We were connected at some point.
this$1.fireEvent('disconnected');
} else {
// We never were connected
reject(ERR_CANNOT_CONNECT);
}
// Try again
var waitTime = Math.min(this$1.connectionTries, 5) * 1000;
setTimeout(function () { return this$1.connect(); }, waitTime);
});
});
};
Connection.prototype.close = function close () {
this.closeRequested = true;
this.socket.close();
};
Connection.prototype.getStates = function getStates () {
return this.sendMessagePromise(states()).then(extractResult);
};
Connection.prototype.getServices = function getServices () {
return this.sendMessagePromise(services()).then(extractResult);
};
Connection.prototype.getPanels = function getPanels () {
return this.sendMessagePromise(panels()).then(extractResult);
};
Connection.prototype.getConfig = function getConfig () {
return this.sendMessagePromise(config()).then(extractResult);
};
Connection.prototype.callService = function callService (domain, service, serviceData) {
return this.sendMessagePromise(callService$1(domain, service, serviceData));
};
// eventCallback will be called when a new event fires
// Returned promise resolves to an unsubscribe function.
Connection.prototype.subscribeEvents = function subscribeEvents (eventCallback, eventType) {
var this$1 = this;
return this.sendMessagePromise(subscribeEvents$1(eventType)).then(
function (resultMessage) {
// We store unsubscribe on info object. That way we can overwrite it in case
// we get disconnected and we have to subscribe again.
var info = {
eventCallback: eventCallback,
eventType: eventType,
unsubscribe: function () { return this$1.sendMessagePromise(unsubscribeEvents(resultMessage.id))
.then(function () { delete this$1.commands[resultMessage.id]; }); },
};
this$1.commands[resultMessage.id] = info;
return function () { return info.unsubscribe(); };
/* eslint-disable comma-dangle */ /* comma crashes Buble */
}
/* eslint-enable comma-dangle */
);
};
Connection.prototype.sendMessage = function sendMessage (message) {
this.socket.send(JSON.stringify(message));
};
Connection.prototype.sendMessagePromise = function sendMessagePromise (message) {
var this$1 = this;
return new Promise(function (resolve, reject) {
this$1.commandId += 1;
var commandId = this$1.commandId;
/* eslint-disable no-param-reassign */
message.id = commandId;
/* eslint-enable no-param-reassign */
this$1.commands[commandId] = { resolve: resolve, reject: reject };
this$1.sendMessage(message);
});
};
function createConnection(url, options) {
var conn = new Connection(url, options);
return conn.connect();
}
exports.ERR_CANNOT_CONNECT = ERR_CANNOT_CONNECT;
exports.ERR_INVALID_AUTH = ERR_INVALID_AUTH;
exports.createConnection = createConnection;
exports['default'] = createConnection;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjpudWxsLCJzb3VyY2VzIjpbIi4uL2xpYi9tZXNzYWdlcy5qcyIsIi4uL2xpYi9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6W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9PiB7XG4gICAgICAgIGNvbnN0IG1lc3NhZ2UgPSBKU09OLnBhcnNlKGV2ZW50LmRhdGEpO1xuXG4gICAgICAgIGlmIChfX0RFVl9fKSB7XG4gICAgICAgICAgLyogZXNsaW50LWRpc2FibGUgbm8tY29uc29sZSAqL1xuICAgICAgICAgIGNvbnNvbGUubG9nKG1lc3NhZ2UpO1xuICAgICAgICAgIC8qIGVzbGludC1lbmFibGUgbm8tY29uc29sZSAqL1xuICAgICAgICB9XG5cbiAgICAgICAgc3dpdGNoIChtZXNzYWdlLnR5cGUpIHtcbiAgICAgICAgICBjYXNlICdhdXRoX3JlcXVpcmVkJzpcbiAgICAgICAgICAgIHRoaXMuc2VuZE1lc3NhZ2UobWVzc2FnZXMuYXV0aCh0aGlzLm9wdGlvbnMuYXV0aFRva2VuKSk7XG4gICAgICAgICAgICBicmVhaztcblxuICAgICAgICAgIGNhc2UgJ2F1dGhfaW52YWxpZCc6XG4gICAgICAgICAgICByZWplY3QoeyBjb2RlOiBFUlJfSU5WQUxJRF9BVVRIIH0pO1xuICAgICAgICAgICAgaW52YWxpZEF1dGggPSB0cnVlO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlICdhdXRoX29rJzpcbiAgICAgICAgICAgIHJlc29sdmUodGhpcyk7XG4gICAgICAgICAgICB0aGlzLmZpcmVFdmVudCgncmVhZHknKTtcblxuICAgICAgICAgICAgLy8gUmUtc3Vic2NyaWJlIHRvIGV2ZW50cyBhbmQgdXBkYXRlIG9sZCBsb2NhdGlvbiBvZiB1bnN1YiBtZXRob2RcbiAgICAgICAgICAgIC8vIHNvIG9sZCB1bnN1YiBtZXRob2Qga2VlcHMgd29ya2luZy5cbiAgICAgICAgICAgIHRoaXMuY29tbWFuZElkID0gMTtcbiAgICAgICAgICAgIHRoaXMuY29tbWFuZHMgPSB7fTtcblxuICAgICAgICAgICAgT2JqZWN0LmtleXMob2xkQ29tbWFuZHMpLmZvckVhY2goKGlkKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IGluZm8gPSBvbGRDb21tYW5kc1tpZF07XG5cbiAgICAgICAgICAgICAgaWYgKGluZm8uZXZlbnRUeXBlKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5zdWJzY3JpYmVFdmVudHMoaW5mby5ldmVudENhbGxiYWNrLCBpbmZvLmV2ZW50VHlwZSlcbiAgICAgICAgICAgICAgICAgIC50aGVuKCh1bnN1YikgPT4geyBpbmZvLnVuc3Vic2NyaWJlID0gdW5zdWI7IH0pO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIGJyZWFrO1xuXG4gICAgICAgICAgY2FzZSAnZXZlbnQnOlxuICAgICAgICAgICAgdGhpcy5jb21tYW5kc1ttZXNzYWdlLmlkXS5ldmVudENhbGxiYWNrKG1lc3NhZ2UuZXZlbnQpO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBjYXNlICdyZXN1bHQnOlxuICAgICAgICAgICAgaWYgKG1lc3NhZ2Uuc3VjY2Vzcykge1xuICAgICAgICAgICAgICB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdLnJlc29sdmUobWVzc2FnZSk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdLnJlamVjdChtZXNzYWdlLmVycm9yKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGRlbGV0ZSB0aGlzLmNvbW1hbmRzW21lc3NhZ2UuaWRdO1xuICAgICAgICAgICAgYnJlYWs7XG5cbiAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgaWYgKF9fREVWX18pIHtcbiAgICAgICAgICAgICAgLyogZXNsaW50LWRpc2FibGUgbm8tY29uc29sZSAqL1xuICAgICAgICAgICAgICBjb25zb2xlLndhcm4oJ1VuaGFuZGxlZCBtZXNzYWdlJywgbWVzc2FnZSk7XG4gICAgICAgICAgIC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T0FBTyxDQUFDLFVBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRTtJQUNyQyxNQUFNLENBQUMsU0FBUyxJQUFJLENBQUMsQ0FBQztJQUN0QixJQUFRLFNBQVMsR0FBR0EsTUFBSSxDQUFDLFNBQVMsQ0FBQzs7SUFFbkMsT0FBUyxDQUFDLEVBQUUsR0FBRyxTQUFTLENBQUM7O0lBRXpCLE1BQU0sQ0FBQyxRQUFRLENBQUMsU0FBUyxDQUFDLEdBQUcsRUFBRSxTQUFBLE9BQU8sRUFBRSxRQUFBLE1BQU0sRUFBRSxDQUFDO0lBQ2pELE1BQU0sQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFDLENBQUM7R0FDM0IsQ0FBQyxDQUFDO0NBQ0osQ0FBQTs7QUFHSCxBQUFPLFNBQVMsZ0JBQWdCLENBQUMsR0FBRyxFQUFFLE9BQU8sRUFBRTtFQUM3Q0YsSUFBTSxJQUFJLEdBQUcsSUFBSSxVQUFVLENBQUMsR0FBRyxFQUFFLE9BQU8sQ0FBQyxDQUFDO0VBQzFDLE9BQU8sSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO0NBQ3ZCLEFBRUQsQUFBZ0M7Ozs7Ozs7OzsifQ==

2

package.json
{
"name": "home-assistant-js-websocket",
"version": "0.1.2",
"version": "0.1.3",
"description": "Home Assistant websocket client",

@@ -5,0 +5,0 @@ "main": "dist/haws.cjs.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc