[ANNOUNCE] node-red-contrib-ui-web-push: beta version

Hey @Paul-Reed,
I think this is not possible. Suppose we would have a separate npm library that contains the config node, which would be loaded as a dependency by both Maxim's and my ui node. But this means the following statement would be called twice:

RED.nodes.registerType('vapid-configuration', VapidConfigurationNode)

Which would result in a "Type already registered" error.
I had hoped to be able to register (in both nodes) the config node type only when not registered yet. Something like this:

if (!RED.nodes.getType('vapid-configuration'))  {
   RED.nodes.registerType('vapid-configuration', VapidConfigurationNode);
}

Then only one of both nodes would register the config node type.
However I don't think I can get access to registry (where all node types are stored), so no getType available ...

Not sure how to continue with this.

Maybe we have come to expect that a single node installation would fulfill both sending and receiving messages, like the email node;
emailex
or MQTT node;

mqtt

...without installing 2 node packages, one for sending, and another for receiving, especially when they are maintained by different authors.
I'm sure you will have considered adding your node as a PR to the Maxim node repo, but no doubt there are good reasons why that couldn't be done.

I'll leave it at that, I'm probably a minority voice here, and it's only my personal opinion.

I'm sure most users will find this a valuable contribution :+1:

Yes of course :wink:
Maxim's nodes already exist a couple of years, and had 889 downloads last year. So it is being used quite a lot, before my UI node was developed. When I would add my UI node to Maxim's node suite, all those users would suddenly get a dashboard node. And I assume that most of those setups won't even have a dashboard installed...

But you are right that I should be able somehow to get a more loose coupling between both nodes. But don't know how at the moment ...

The node doesn't have to appear if the dashboard isn't installed, eg see my worldmap.

Hey Dave, do I need to add something special to the code then?

Well, you have to check to see if dashboard exists, but not sure that counts as special.

Ok thabks for the proposal. Will discuss this with Maxim...

I have asked it, so now waiting for an answer.
But it feels a bit wrong that I cannot share a config with other nodes... E.g. I have a series of nodes (onvif, rtsp stream, multipart decoder, http request...) which all require an ip adress / username / password. So I have to enter the same data N times. Although perhaps it wouldn't be safe that nodes can access the config data of other nodes...
But this is too much off-topic of course...

but not necessarily the same ones.. but yes off topic for this thread.

Will the notification work on a PC (linux) too?

Hi @colin,
I don't have a linux pc, but seems it should work.

OK, thanks.

Does web push not work unless https is enabled?
I only want to use it on a local network but I can imagine the s/w not allowing the feature without https.

Indeed on some browsers (e.g. Chrome) https is required, otherwise you cannot install service workers. And as explained above, some browsers (again e.g. Chrome) don't allow self-signed certificates.

FWIW, Telegram doesn't always work that well and delays can be a problem. Look forward to trying this solution.

Hey guys,
Maxim has been so kind to make me contributor to his repository, so I have added my UI node to it.
But this is 100% against my nature ( :frowning_face: ):

  • The UI stuff is miles away from Maxim's stuff,
  • Don't like to intrude in the repository from somebody else
  • I need to bother him every time I want to publish a new version on npm
  • We both have different styles of documenting
  • ...

So would like to keep the repositories separated, if possible ...
Therefore I have tried another experiment to share the config nodes between Maxim's node-red-contrib-web-push and my node-red-contrib-ui-web-push, and still being able to install each both nodes without the other (and have no failure).

I think I found a solution/workaround (based on a global const issue of @Steve-Mcl a couple of days ago) :

  • Maxim's module contains the VAPID config node. However instead of always registering that config node, I install it conditionally if a global variable exists:

    if (!VapidConfigurationNodeHasBeenInstalled) {
       RED.nodes.registerType('vapid-configuration', VapidConfigurationNode);
       var VapidConfigurationNodeHasBeenInstalled = true;
       console.log("The Vapid config node has been installed for Maxim's node-red-contrib-web-push node")
    }
    
  • I add the same config node to my own module, and also register it conditionally based on the SAME GLOBAL VARIABLE:

    if (!VapidConfigurationNodeHasBeenInstalled) {
       RED.nodes.registerType('vapid-configuration', VapidConfigurationNode);
       var VapidConfigurationNodeHasBeenInstalled = true;
       console.log("The Vapid config node has been installed for Bart's node-red-contrib-ui-web-push node")
    }
    
  • As a result only one of both modules will register the VAPID config node (the other module not because then the global variable has been declared meanwhile):

    image

So you can install both nodes independently of each other, and they seem to be able to share the config nodes. That seems to me normal behaviour...

  • Does somebody see a disadvantage?
  • Not sure whether the VAPID config node code (html and js files) should be copied in my repository, or should we create a separate third module (and both Maxim's an my modules have a dependency to that common module)? If in the future that common module is updated on npm, then both our modules will have the update.

Thoughts?

I can confirm that running the Waterfox Classic browser (a firefox fork) in Ubuntu 19.10, connected via the local network, that https is not required. It works fine with http. There are not any security risks associated with doing this are there? Provided node-red is not open to the internet of course.

I have noticed a small typo in the README, in the section Node Usage, point 1 it says "your dashboard is secured with http " where I think you menat it to be https.
However it does appear that on the local network some browsers will allow it with just http.

Yes especially Chrome is very strict...

Ok need to think about changing that...

If you have tried some browsers, please let me know. I will add it to the readme page.

Yes, but then the dashboard won't open of course, when you click on the notification. Don't think that there are extra security issues. Just that exchange your VAPID keys over a non-secure line: if somebody would intercept those, they could send notifications to your device. But then you just unsubscribe and create a new keypair. So don't think that will soon hapoen.

Bart - re your idea re shared config, indeed that would be a way to do it. But forgive me for forgetting where this started. Is it only the config node you need to share ? or does this web push rely on the rest of his node for some functionality it brings ? If so then why not just make it a dependancy of your node ? So that way it will always get installed including the config node.

Yes it will, provided I am on the local network. I want this for on the PC remember, not the phone. When I am out with my laptop (not much chance of that at the moment though) then I connect via the VPN so again it should work, hopefully.

I have noticed on the PC that I need the browser running in order to receive the notification.

I have also realised that it only works on localhost (on http). It is not the fact that it is on the local network but the fact that it is on localhost that is significant.

Well the config node is REALLT required, which means: if you haven't installed Maxim's nodes, then the config dropdown on my screen is empty (you cannot select or create configs, since Node-RED cannot find the confih node type). That would be solved by my global variable setup, because the my node 'could' register the config node type.
The other nodes from Maxim are also required (but not that tight), because they send the push notifications to the device...

Ah is that posdible, to have a Node-RED node as a dependency for another Node-RED node? Thought that this might perhaps mess up the whole manage palette setup...

I should mention that on the readme also...

Again readme stuff. Keep going :+1: