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

homebridge-syntex-ui

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-syntex-ui - npm Package Compare versions

Comparing version 1.0.1-b2 to 1.0.1-b3

26

js/data-storage.js

@@ -45,2 +45,24 @@ class DataStorage

setClient(clientID)
{
if(clientID != null)
{
this.remote['client-id'] = clientID;
try
{
localStorage.setItem('remote', JSON.stringify(this.remote));
}
catch(e)
{
console.error(e);
}
if(window.ServiceWorker != null)
{
window.ServiceWorker.sendMessage({ clientID });
}
}
}
setSession(sessionID)

@@ -65,3 +87,3 @@ {

{
window.ServiceWorker.updateSession(sessionID);
window.ServiceWorker.sendMessage({ sessionID });
}

@@ -86,3 +108,3 @@ }

{
window.ServiceWorker.updateSession();
window.ServiceWorker.sendMessage({ sessionID : 'RESET' });
}

@@ -89,0 +111,0 @@ }

30

js/essentials.js

@@ -1112,20 +1112,20 @@ let self = null;

{
if(window.ServiceWorker != null)
var id = Storage.getRemote('client-id'), settings = Storage.getItem('notifications') || {},
key = button.getAttribute('name'), value = button.checked || (button.value == 'An');
if(window.ServiceWorker != null && id != null && key != null)
{
var key = button.getAttribute('name'), value = button.checked,
notificationSettings = Storage.getItem('notifications') || {};
settings[key] = value;
if(button.getAttribute('type') == 'button')
{
value = (button.value == 'An');
}
window.Query.fetchURL(window.location.protocol + '//' + window.location.hostname + ':8888/serverside/subscribe', 3000, JSON.stringify({ id, settings })).then((data) => {
if(key != '')
{
notificationSettings[key] = value;
Storage.setItem('notifications', notificationSettings);
window.ServiceWorker.setPushSettings(notificationSettings);
}
if(data != null && data != 'Error')
{
Storage.setItem('notifications', settings);
}
else
{
// TODO: Add Dialogues When Failed
}
});
}

@@ -1132,0 +1132,0 @@ }

@@ -411,3 +411,4 @@ {

"chosen": "Ausgewählt",
"updates": "Updates"
"updates": "Updates",
"notifications": "Mitteilungen"
},

@@ -414,0 +415,0 @@ "sort": {

@@ -411,3 +411,4 @@ {

"chosen": "Ausgewählt",
"updates": "Updates"
"updates": "Updates",
"notifications": "Mitteilungen"
},

@@ -414,0 +415,0 @@ "sort": {

@@ -411,3 +411,4 @@ {

"chosen": "Chosen",
"updates": "Updates"
"updates": "Updates",
"notifications": "Notifications"
},

@@ -414,0 +415,0 @@ "sort": {

@@ -411,3 +411,4 @@ {

"chosen": "Chosen",
"updates": "Updates"
"updates": "Updates",
"notifications": "Notifications"
},

@@ -414,0 +415,0 @@ "sort": {

{
"name": "homebridge-syntex-ui",
"version": "1.0.1-b2",
"version": "1.0.1-b3",
"description": "A plugin to control SynTex accessories: https://github.com/SynTexDZN/homebridge-syntex-ui",

@@ -5,0 +5,0 @@ "main": "main.js",

{
"9b1efdb7e4275d6ff6ab81913add9d0e": 1583,
"18b6d3cfca6bec531d7a521d43a38d06": 290,
"d41219060e0c16c228ed4682cade6379": 165
"9b1efdb7e4275d6ff6ab81913add9d0e": 1618,
"18b6d3cfca6bec531d7a521d43a38d06": 294,
"d41219060e0c16c228ed4682cade6379": 188
}

@@ -85,3 +85,3 @@ {

"version": "5.4.2-b36",
"activity": 1681858922544
"activity": 1681861421093
},

@@ -91,3 +91,3 @@ {

"version": "2.3.8-b20",
"activity": 1681858922544
"activity": 1681861421093
},

@@ -97,3 +97,3 @@ {

"version": "1.2.2-b16",
"activity": 1681858922544
"activity": 1681861421092
},

@@ -103,3 +103,3 @@ {

"version": "1.2.4-b13",
"activity": 1681858922544
"activity": 1681861421092
},

@@ -109,3 +109,3 @@ {

"version": "1.0.3-b16",
"activity": 1681858922545
"activity": 1681861421093
}

@@ -112,0 +112,0 @@ ],

{
"9b1efdb7e4275d6ff6ab81913add9d0e": [
{
"endpoint": "https://fcm.googleapis.com/fcm/send/fMz2aiIWqic:APA91bFoX1Z-VS9i5pWkQ2bG_GnENXZzCNgReKMNNBC4uetMQYV0v8M1IC2AX6Ot4z916oY0cJ8chSyCpiphJKVioaFq0gsGu3-aCFZSl4xg734v-VpHajFEsSFlPDFuLGpddrss9ZP6",
"endpoint": "https://fcm.googleapis.com/fcm/send/eNp6xqiGv5M:APA91bEFkOHtw3G8V7efh_FGrlOrSb5sqCmxCH1exIPKie6W-0lIlwKKJfpmcOv_RwbNm28JldUyzqeLCCztPnrfPiGwfOI7z1EB2t5Jafe4CbBTlAO69OtN9SiQZyuwJpL17OEzeInt",
"expirationTime": null,
"keys": {
"p256dh": "BGOz7IB-KMBxo2OSj_iqlsU_4EnBzXX_da_EnbkkD9-jrGD4bBFZV2kirLERGyhS_ViEpc-s9Bjl1klzc0D7MoA",
"auth": "YJZHM-toLCTyyz0RCKEltQ"
"p256dh": "BCWVytF7PE--H-2MGCO48iYi7Sqb152yYT9A8Xf5ttJGo1gH3ZafcXBYnva_Z69C8jSgnUk6XUIBwPDyULJxz0M",
"auth": "Nk7MVh783cQBMFosTgxQ-g"
}
},
{
"endpoint": "https://web.push.apple.com/QLTnaVP8u0j9py68dt3oyU9G-xJHacHuN_hSXDNgFMmkBjEmu0XI0jHQDbYkgw7Qfdv-3trseY6qoNyBCLyuWoeKOUKj9OgJuL99dd5gLvYHAhikTWpPizD_rY5DmiAgXahelfpedE18Pgj-cOfCd2iNw1op08iMrHEzdqdQYXE",
"endpoint": "https://web.push.apple.com/QD6-VMaF05ahBS-MseiL2jNOL2lunKrR8z4Wxd4Y8RIooE64UF8uwj8D4c4zAy8ovzBcfoZ1I7znQosSGBk8KMCtv_qSStEo3LMbufaYA9SudO4WBlTt1QoE7RpwqQBZWutR2MonfwJjatHJWy3TQrUD62061lWHRF8mkNiMLT8",
"keys": {
"p256dh": "BGBsCizI5IfZf-zbEOg2MxyiLjgtWRXY7OVn1uou8YoHHCD9FV-_-7QsTFgTUW_NFcxoYieTbTIg2HKI-UM1JYY",
"auth": "giJaycpMc06qyQVrCTxa1g"
"p256dh": "BMqI_mP_txkx89g0XUWi0x9StMlNO70muKcUQQfE-AMoSxIsEB1RffM7qmtdoM8aPcWvLuk93d945GAFly_DSCU",
"auth": "6SmhxRSdx1PdumgKgnpWgA"
}

@@ -21,6 +21,6 @@ }

{
"endpoint": "https://web.push.apple.com/QA_q19yJMG33RPKVOGSM2lNmVlTyhHXV1nkhGWTRn3AQVh6kqbkxx5c6Xwe_V0NIDalCmNr3Sv_9UMc1yNxfj1zPTYzG7xqhH2zws-6_csZlecRqYYJ7EOeS-k8BQPoLt8QTmOG0P0rndEjIj2xr3TLKGkY1g8v_YnvxxuhDrhw",
"endpoint": "https://web.push.apple.com/QNrQvGuuOji_Jmjcy67j8Jv5xQwMuGGpq4sr2jiACF8vL5kj_31xKYC_duIBAhf29t1as3OVl_eArTgyeJNSqKL5qK_JvF13dcPlWKP0AsZL_KkXJhUS7o_D0ZY1l4Io4iK2NybyPAmdesC-2XyCfhnlqc6F8kbXWZXHdFR7oug",
"keys": {
"p256dh": "BEGSEuRJIa2EEr1j3wU-0Y-Tp1kaol-9cskqjnTeqSv6yW5x4SkNTuoTGnxE0hQWpMP07PzjZ9uh_KozrcDpHsw",
"auth": "XNkHXnC5cD2NqL6m-dgT6g"
"p256dh": "BC8wIyXXmBLLrXrLhbgFAq0IqwRF16NPvWjP8RqKE5jPk1_zbjBSJuJeD577c_7k3B8IjP58-8wK044u_c6hjTM",
"auth": "OkTMpbEPqRFLIV6Jzhcyvw"
}

@@ -31,9 +31,16 @@ }

{
"endpoint": "https://web.push.apple.com/QHpwMRw2wyq6lMNTxk2p1R2PvGzjqC0nHZdMuTz2919qrcUccjkBUB6ZcLcb2NrkinhynW5tqX_u8xhr1MD8Ehzk4ZQOWou1u6iQcPGcRm6g5ABGQoCHkhz3S-C4otZPEzVwDyGbktXoqHt_Ocr5r4VIqX88dQZu1gT2B9wDAAE",
"endpoint": "https://web.push.apple.com/QPA_GmrA10E0sGdamKrk2CmHmLR_cFij09FlKOCAx9DHumcIs2Imer6Btix_Uw-lkBSfYhEnZJah-QnzOX37g08OqPQ4rBnKWbOXhkLJ4ApEPSoVe-jGlOIjd7H3gi74yQtI5qTCINcAhiLPItoZpIgopXdp013x4rEGUKyVONo",
"keys": {
"p256dh": "BApV4IZi6bXeudnIRPha5nEI569hMXtQ0Yu5BeZl5mVEv--3KOCqD5WUoUsylCCPmZrj-FAhvZ9K84mPQlIV1SI",
"auth": "RzAY3zuTagvBFUrIr-RqIQ"
"p256dh": "BO3i-Zq9Uy_xT-Kffkt9jrCDcV9mLSl8gGnycvz8dCbNTejp1di1W4NAqDnhy9LQSpdAqmdwi3ySJKh09QFa9qg",
"auth": "wPM0fXo0gBIlNzPzqrVyVg"
}
},
{
"endpoint": "https://web.push.apple.com/QJV7ZJV9yC83CXboDrx6XckdQZWXWI07j35386_Wy-ZSeBYdtQZtLU602qhe8ZJrb0ffJRX8fFeXa-zYlYUpBjT61iL8rg5vIlPkrqGjMUohwzF6X6fq4HaxFJc0NruRv90OwdEvlWdfhFbeHTm2vnB460L13XsOGZFdiMShPV8",
"keys": {
"p256dh": "BPihGGpam9gRFd1LK8dpthjpODloqNJqWEJS3QIakV8ytrS9eqENV7k45-tVLNPdF13LEzkLpJeQZNOBQka2NW0",
"auth": "qrn7BhRl8V1pUYhgyOiH3A"
}
}
]
}

@@ -8,3 +8,2 @@ const WebPush = require('web-push');

this.subscriptions = {};
this.badges = {};

@@ -35,6 +34,4 @@ this.logger = platform.logger;

{
var promiseArray = [];
return new Promise((resolve) => {
promiseArray.push(new Promise((resolve) => {
this.FileManager.readFile('server/data/subscriptions.json').then((subscriptions) => {

@@ -49,18 +46,3 @@

});
}));
promiseArray.push(new Promise((resolve) => {
this.FileManager.readFile('server/data/badges.json').then((badges) => {
if(badges != null)
{
this.badges = badges;
}
resolve();
});
}));
return Promise.all(promiseArray);
});
}

@@ -79,13 +61,2 @@

saveBadgeData()
{
return new Promise((resolve) => {
this.FileManager.writeFile('server/data/badges.json', this.badges).then((response) => {
resolve(response.success);
});
});
}
initWebServer()

@@ -99,26 +70,37 @@ {

{
if(post.unsubscribe)
if(post.subscription != null)
{
this.removeSubscription(user, post);
var id = post.id || this.generateID(), payload = JSON.stringify({ title : 'Aktivierung der Mitteilungen' });
this.logger.debug('[' + user.name + '] hat seine Mitteilungen deaktiviert! ( ' + (this.subscriptions[user.username] || []).length + ' Geräte )');
this.addSubscription(user, id, post.subscription);
WebPush.sendNotification(post.subscription, payload).catch((error) => this.logger.err(error));
if(post.settings != null)
{
this.setSettings(user, id, post.settings);
}
response.end(JSON.stringify({ id }));
this.logger.debug('[' + user.name + '] hat seine Mitteilungen aktiviert! ( ' + Object.keys(this.subscriptions[user.username] || {}).length + ' Geräte )');
}
else
else if(post.id != null && post.unsubscribe != null)
{
var payload = JSON.stringify({ title : 'Aktivierung der Mitteilungen' });
this.removeSubscription(user, post.id);
this.addSubscription(user, post);
/*
setInterval(() => {
response.end('Success');
WebPush.sendNotification(post, payload).catch((error) => this.logger.err(error));
this.logger.debug('[' + user.name + '] hat seine Mitteilungen deaktiviert! ( ' + Object.keys(this.subscriptions[user.username] || {}).length + ' Geräte )');
}
else if(post.id != null && post.settings != null)
{
response.end(this.setSettings(user, post.id, post.settings) ? 'Success' : 'Error');
}, 10000);
*/
WebPush.sendNotification(post, payload).catch((error) => this.logger.err(error));
this.logger.debug('[' + user.name + '] hat seine Mitteilungen aktiviert! ( ' + (this.subscriptions[user.username] || []).length + ' Geräte )');
this.logger.debug('[' + user.name + '] hat seine Push-Einstellungen aktualisiert! ( ' + Object.keys(post.settings).length + ' Einstellungen )');
}
response.end(JSON.stringify(this.badges[user.username] || 0));
else
{
response.end('Error');
}
}

@@ -133,9 +115,9 @@ else

if(post != null && post.sessionID != null)
if(post != null && post.sessionID != null && post.clientID != null)
{
var user = this.UserManager.getUser({ sessionID : post.sessionID });
if(user != null)
if(user != null && this.subscriptions[user.username] != null && this.subscriptions[user.username][post.clientID] != null)
{
response.end(JSON.stringify(this.badges[user.username] || 0));
response.end(JSON.stringify(this.subscriptions[user.username][post.clientID].badge));
}

@@ -154,17 +136,29 @@ else

addSubscription(user, subscription)
addSubscription(user, clientID, subscription)
{
var found = false;
if(this.subscriptions[user.username] == null)
{
this.subscriptions[user.username] = [];
this.subscriptions[user.username] = {};
}
for(const i in this.subscriptions[user.username])
this.subscriptions[user.username][clientID] = { badge : 0, subscription };
this.saveSubscriptionData();
}
removeSubscription(user, clientID)
{
var found = false;
if(this.subscriptions[user.username] != null
&& this.subscriptions[user.username][clientID] != null)
{
if(this.subscriptions[user.username][i].endpoint == subscription.endpoint)
delete this.subscriptions[user.username][clientID];
if(Object.keys(this.subscriptions[user.username]).length == 0)
{
found = true;
delete this.subscriptions[user.username];
}
found = true;
}

@@ -174,4 +168,2 @@

{
this.subscriptions[user.username].push(subscription);
this.saveSubscriptionData();

@@ -181,25 +173,26 @@ }

removeSubscription(user, subscription)
getSubscription(user, clientID)
{
var found = false;
for(const i in this.subscriptions[user.username])
if(this.subscriptions[user.username] != null && this.subscriptions[user.username][clientID] != null)
{
if(this.subscriptions[user.username][i].endpoint == subscription.endpoint)
{
this.subscriptions[user.username].splice(i, 1);
found = true;
}
return this.subscriptions[user.username][clientID];
}
if(this.subscriptions[user.username] != null && this.subscriptions[user.username].length == 0)
return null;
}
setSettings(user, clientID, settings)
{
var subscription = this.getSubscription(user, clientID);
if(subscription != null)
{
delete this.subscriptions[user.username];
}
subscription.settings = settings;
if(found)
{
this.saveSubscriptionData();
return true;
}
return false;
}

@@ -213,3 +206,3 @@

if(user != null && user.bridges != null)
if(user != null && user.bridges != null && this.subscriptions[username] != null)
{

@@ -220,11 +213,4 @@ for(const remoteID in user.bridges)

{
if(this.badges[username] == null)
{
this.badges[username] = 0;
}
var found = false;
this.badges[username]++;
notification.badge = this.badges[username];
if(notification.title == null)

@@ -235,10 +221,23 @@ {

for(const subscription of this.subscriptions[username])
for(const clientID in this.subscriptions[username])
{
WebPush.sendNotification(subscription, JSON.stringify(notification)).catch((error) => this.logger.err(error));
if(notification.type == null
|| (this.subscriptions[username][clientID].settings != null && this.subscriptions[username][clientID].settings[notification.type]))
{
this.subscriptions[username][clientID].badge++;
notification.badge = this.subscriptions[username][clientID].badge;
WebPush.sendNotification(this.subscriptions[username][clientID].subscription, JSON.stringify(notification)).catch((error) => this.logger.err(error));
found = true;
}
}
this.saveBadgeData();
if(found)
{
this.saveSubscriptionData();
this.logger.debug('[' + bridgeID + '] --> [' + notification.body + '] --> [' + user.name + ']');
this.logger.debug('[' + bridgeID + '] --> [' + notification.body + '] --> [' + user.name + ']');
}
}

@@ -249,2 +248,7 @@ }

}
generateID()
{
return new Date().getTime().toString(16);
}
}

@@ -56,2 +56,4 @@ const version = 'v1.0.1';

self.registration.showNotification(data.title, data);
caches.open('config').then((cache) => {

@@ -61,5 +63,5 @@

{
getCacheData(cache, '/cache/session').then((session) => {
getCacheData(cache, '/cache/session').then((session) => getCacheData(cache, '/cache/client').then((client) => {
if(session != null)
if(session != null && client != null)
{

@@ -70,7 +72,7 @@ var headers = new Headers();

fetch(location.protocol + '//' + location.hostname + ':8888/serverside/badge', { method : 'POST', body : JSON.stringify({ sessionID : session.sessionID }) }).then((response) => {
fetch(location.protocol + '//' + location.hostname + ':8888/serverside/badge', { method : 'POST', body : JSON.stringify({ sessionID : session.sessionID, clientID : client.clientID }) }).then((response) => {
response.text().then((responseText) => {
getCacheData(cache, '/cache/badge').then((current) => getCacheData(cache, '/cache/push-settings').then((settings) => {
getCacheData(cache, '/cache/badge').then((current) => {

@@ -85,14 +87,9 @@ var currentBadgeCounter = 0, badgeCounter = parseInt(responseText);

navigator.setAppBadge(badgeCounter - currentBadgeCounter);
if(data.type == null || (settings != null && settings[data.type] == true))
{
self.registration.showNotification(data.title, data);
}
cache.put('/cache/push', new Response(JSON.stringify({ badgeCounter }), { status : 200 })).then(() => resolve());
}));
resolve();
});
});
});
}
});
}));
}

@@ -105,3 +102,3 @@ });

console.log('[ServiceWorker] hat das \'pushsubscriptionchange\' erhalten!');
console.log('[ServiceWorker] hat eine Änderung der Push-Subscription erhalten!');

@@ -113,21 +110,14 @@ var options = {

event.waitUntil(self.registration.pushManager.subscribe(options).then(async (subscription) => {
event.waitUntil(self.registration.pushManager.subscribe(options).then((subscription) => {
// TODO: Send Message To Client And Fetch
if (!event.clientId) return;
if(subscription)
{
fetch(location.protocol + '//' + location.hostname + ':8888/serverside/subscribe').then((data) => {
self.clients.get(event.clientId).then((client) => {
});
}
if(client)
{
client.postMessage({
msg : 'Hey I just got a fetch from you!',
url : event.request.url,
});
}
});
//Query.fetchURL('https://syntex-cloud.com:8888/serverside/subscribe', 3000, JSON.stringify(subscription));
console.log('[ServiceWorker] hat eine neue Push-Verbindung!', subscription);

@@ -152,3 +142,3 @@ }));

{
if(data.sessionID)
if(data.sessionID != null)
{

@@ -165,3 +155,3 @@ if(data.sessionID != 'RESET')

if(data.currentBadge)
if(data.currentBadge != null)
{

@@ -171,18 +161,29 @@ cache.put('/cache/badge', new Response(JSON.stringify({ badgeCounter : data.currentBadge }), { status : 200 }));

if(data.clearAppBadge)
if(data.clearAppBadge != null)
{
getCacheData(cache, '/cache/push').then((data) => {
navigator.clearAppBadge();
getCacheData(cache, '/cache/session').then((session) => getCacheData(cache, '/cache/client').then((client) => {
if(data != null)
if(session != null && client != null)
{
cache.put('/cache/badge', new Response(JSON.stringify({ badgeCounter : data.badgeCounter }), { status : 200 }));
fetch(location.protocol + '//' + location.hostname + ':8888/serverside/badge', { method : 'POST', body : JSON.stringify({ sessionID : session.sessionID, clientID : client.clientID }) }).then((response) => {
response.text().then((data) => {
if(data != null && data != 'Error' && !isNaN(parseInt(data)))
{
var badgeCounter = parseInt(data);
cache.put('/cache/badge', new Response(JSON.stringify({ badgeCounter }), { status : 200 }));
}
});
});
}
});
navigator.clearAppBadge();
}));
}
if(data.pushSettings)
if(data.clientID != null)
{
cache.put('/cache/push-settings', new Response(JSON.stringify(data.pushSettings), { status : 200 }));
cache.put('/cache/client', new Response(JSON.stringify({ clientID : data.clientID }), { status : 200 }));
}

@@ -189,0 +190,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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