Create a gist now

Instantly share code, notes, and snippets.

@matzew /sph.md Secret
Last active Dec 20, 2015

What would you like to do?
SimplePush Hack

SimplePush by hand

  1. establish WSS connection
var websocket = new WebSocket("wss://push.services.mozilla.com");
websocket.onopen = function(event) {alert("OPEN");};
websocket.onclose = function(e) {alert('closed')};
websocket.onmessage = function(e) {console.log(e.data); };

once 'open'ed send HELLO:

var helloMsg = {messageType: "hello",uaid: "",channelIDs: []};
websocket.send(JSON.stringify( helloMsg ));

After payload received, did an register:

var reg = {"messageType": "register","channelID": "d9b74644-4f97-46aa-b8fa-9393985cd6cd"};
websocket.send(JSON.stringify( reg ));

From that payload, use the pushEndpoint URL string, in a cURL, like:

curl -i --header "Content-Type:application/x-www-form-urlencoded" -X PUT -d "version=2" 
https://push.services.mozilla.com/update/MGlYke2SrEmYE8ceyuSTwxawxuEJnMeHtTCFDckvUo9Gwat44C5Z5vjlQEd1od1hj6o38UB6Ytc5xgXwSLAH2VS8qKyZ1eLNTQSX6_AEeH73ohUy2A==

And noticed a logged update :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment