{"_id":"c2dm","_rev":"26-938bdd0ec6176400a7aca27a5a9356ff","name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.0.0","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"/lib/c2dm","repository":{"type":"git","url":"http://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"_id":"c2dm@1.0.0","_engineSupported":true,"_npmVersion":"0.2.16","_nodeVersion":"v0.2.6","directories":{"lib":"./lib"},"modules":{"c2dm.js":"lib/c2dm.js"},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"defb5d2903761d8ac626ab8ff8215d5966b1462a","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.0.0.tgz","integrity":"sha512-DzOJ/c4mFwuQfwOVMB0QqQZpygAEFIjzbAmHWW/uxR7hz1/b/fuptCIXbQ41odWt1Do3YiYc7uHeO0NOo/HeJw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGJ+t9Pz6WIEwjH78khiJdQnQs/UJmn81P2Y/Bo0KBfAIgPWUpbdYRpb0iWO3N1qiymHXTdg8xxP1tzRA9XKjacYg="}]}},"1.0.1":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.0.1","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"git://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"_id":"c2dm@1.0.1","_engineSupported":true,"_npmVersion":"0.3.18","_nodeVersion":"v0.4.5","directories":{"lib":"./lib"},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"64e45ad94a3d12bdf62077abef8cf0ebf1ac7dcd","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.0.1.tgz","integrity":"sha512-wNSTKytZwR8cPXcW1xzRwGvTuziVPZGd/7/wv6mnijWwgPxlBFRLsGJRB798Ga4H3xxTailTcFRmV9QeM4400g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICWJItIaQE9NX4fmA0HO9lEcbF2okNUX1WUG5o1PbidOAiB3DpjQFSqw4dkQhijgK3zo5J9qWRagQrx86W7mJrSLCQ=="}]}},"1.0.2":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.0.2","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"git://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"_id":"c2dm@1.0.2","_engineSupported":true,"_npmVersion":"0.3.18","_nodeVersion":"v0.4.5","directories":{"lib":"./lib"},"files":[""],"_defaultsLoaded":true,"dist":{"shasum":"213ee4c0c5466c39d7564e1bbe9eda5ae770311d","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.0.2.tgz","integrity":"sha512-6Q+/2i0CSdQFl8J8uwxS3qfLP8ZmpwQGAg8mgzKnsnQZJSk9aKTM90qYqzvSPzmo01RUuRtuoJyy795WDa/FkQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEmto5UYX50V1nY0MgjUDEtqUqByPEKiFxv89JxYv4lDAiBlugGrAJHrfmPB5rM+Vl+BtTdqQycgM3tPCnEXUFi7Rg=="}]}},"1.0.3":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.0.3","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"git://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"_npmJsonOpts":{"file":"/Users/yuryproshchenko/.npm/c2dm/1.0.3/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"c2dm@1.0.3","dependencies":{},"devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.24","_nodeVersion":"v0.4.10","_defaultsLoaded":true,"dist":{"shasum":"013cc83f9f18188d7387182dd4c0beed3c3f982a","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.0.3.tgz","integrity":"sha512-jbcvXgH6Nl+rNxqqbCQ7OVftYCCvxLN12G8N1LgQZ8gYfgiIXSvOUR/3Df/JaSYTb3LXGq945HC1mvpShGoozA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC6EOBsXKdq6XuH3Bn5fNsEAy7VR3QfvkS5QmwofOmj+AiEAwi9dETI09dND9/sDXISQueCBC93Uav2f9FH0l/9kGtk="}]},"scripts":{},"maintainers":[{"name":"spect","email":"spect.man@gmail.com"}],"directories":{}},"1.0.4":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.0.4","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"git://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"_npmUser":{"name":"spect","email":"spect.man@gmail.com"},"_id":"c2dm@1.0.4","dependencies":{},"devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.4","_nodeVersion":"v0.6.12","_defaultsLoaded":true,"dist":{"shasum":"c6e97baf794a08cd5e89c9b3264b0ff29df8305a","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.0.4.tgz","integrity":"sha512-PUNxb5btA0tFnbyUc4bHS2aArZ9hybszyHQ+aPJ/ZIbP0VgfHjs0y6RhDk1yvfGeUTrULyqjvEc5gCUMYlKLoA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDNAazTnfrh+uWw34x6NqN/751xpAjCsoy+xf9QzQKArQIgB9v932qMtoD7/OCfy7MtgD9u0iIRESzTl93ENOj0P38="}]},"readme":"# node-c2dm\nAn interface for [Android Cloud to Device Messaging][1] push notification service for Node.js\n\n## Installation\n\nVia [npm][4]:\n\n    $ npm install c2dm\n    \nAs a submodule of your project\n\n    $ git submodule add http://github.com/SpeCT/node-c2dm.git c2dm\n    $ git submodule update --init\n\n## Usage\n### Load in the module\n\n    var C2DM = require('c2dm').C2DM;\n\n### Create a connection\nSee [Google Client Login documentation][2] for details.\n\n    var config = {\n        user: 'bla-blah-blah@gmail.com',\n        password: 'your-huge-very-very-strong-password',\n        source: 'yourCompany-yourMegaApp-version', \n    };\n    var c2dm = new C2DM(config);\n\n### Login into c2dm\n\n    c2dm.login(function(err, token){\n        // err - error, received from Google ClientLogin api\n        // token - Auth token\n    });\n    \n### Send message to device\nSee [C2DM documentation][3] for details.\n\n    var message = {\n        registration_id: 'Device registration id',\n        collapse_key: 'Collapse key',\n        'data.key1': 'value1',\n        'data.key2': 'value2',\n        delay_while_idle: '1' // remove if not needed\n    };\n    \n    c2dm.send(message, function(err, messageId){\n\n    });\n\n### Avoiding login procedure\nYou can avoid login procedure by manually setting Google ClientLogin Auth tokin in config for connection.\nFirst of all you need to get this token by executing next command after replacing `ROLE_EMAIL`, `ROLE_PASSWORDPASS` and `YOURCOMPANY-YOURAPP-Version` with your data:\n\n    $ curl -X POST https://www.google.com/accounts/ClientLogin -d Email=ROLE_EMAIL -d Passwd=ROLE_PASSWORDPASS -d accountType=HOSTED_OR_GOOGLE -d service=ac2dm -d source=YOURCOMPANY-YOURAPP-Version\t\n\nYou will receive three lines. Skip `SID` and `LSID` and copy line starting with `Auth=`. Next include 'token' property into config data and fill it with this `Auth=...` line:\n\n    var config = {\n        token: 'Auth=VVVVEEERY-HUDE-TOKEN',  // N.B. include with Auth= prefix\n    };\n    var c2dm = new C2DM(config);\n\n### Keep-alive connection\nThis module supports Connection: keep-alive header too keep connection to c2dm gate established. You could use it by simply including property in config:\n\n    var config = {\n        ...\n        keepAlive: true,  // it is false by default\n    };\n\n\n## Credits\n\nWritten and maintained by [Yury Proshchenko][5].\n\n## License\n\nThe MIT License\n\nCopyright (c) 2011 Yury Proshchenko (spect.man@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[1]: http://code.google.com/android/c2dm/index.html\n[2]: http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#Request\n[3]: http://code.google.com/android/c2dm/index.html#push\n[4]: http://github.com/isaacs/npm\n[5]: mailto:spect.man@gmail.com\n\n## Changelog\n\n1.0.4\n\n  - Handle scenario where 'close' event is emitted before 'end' event (node 0.4.x)\n\n1.0.3\n\n  - Converted internal subscription method from on(2) to once(2)\n  - Published to npm\n\n1.0.2\n\n  - Fixed 'Content-length missing' error\n\n1.0.1\n\n  - Fixed package.json (thanks Mohd Faruq aka ruqqq)\n  - Fixed 'socked hang up' error (once again thanks Mohd Faruq aka ruqqq)\n\n1.0.0:\n\n  - Initial release","maintainers":[{"name":"spect","email":"spect.man@gmail.com"}],"directories":{}},"1.1.0":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.1.0","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"git://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"dependencies":{"retry":">=0.6.0"},"_npmUser":{"name":"spect","email":"spect.man@gmail.com"},"_id":"c2dm@1.1.0","devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.12","_nodeVersion":"v0.6.14","_defaultsLoaded":true,"dist":{"shasum":"68afc5e4e44aa74ae37fe530439b2edd0f42115d","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.1.0.tgz","integrity":"sha512-juzvy0YFQWfx1KwenuHZplAQSTU7n1iZkTl2aFx9YyhHnm6lmLhO8xCMpamB5EmN6b8RRxR4ztqVSd/gZvW93Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAWhEJzipW/O3FfNg9HEAs7VMfl+GXO2W3UnuPm5YC/1AiEAxrOFit50FmSc5U9toaUcWmS9j85QbuDyBoYuVumvKas="}]},"readme":"# node-c2dm\nAn interface for [Android Cloud to Device Messaging][1] push notification service for Node.js\n\n## Installation\n\nVia [npm][4]:\n\n    $ npm install c2dm\n\nAs a submodule of your project\n\n    $ git submodule add http://github.com/SpeCT/node-c2dm.git c2dm\n    $ git submodule update --init\n\n## Usage\n### Load in the module\n\n    var C2DM = require('c2dm').C2DM;\n\n### Create a connection\nSee [Google Client Login documentation][2] for details.\n\n    var config = {\n        user: 'bla-blah-blah@gmail.com',\n        password: 'your-huge-very-very-strong-password',\n        source: 'com.company.app-name',\n    };\n    var c2dm = new C2DM(config);\n\n### Login into c2dm\n\n    c2dm.login(function(err, token){\n        // err - error, received from Google ClientLogin api\n        // token - Auth token\n    });\n    \n### Send message to device\nSee [C2DM documentation][3] for details.\n\n    var message = {\n        registration_id: 'Device registration id',\n        collapse_key: 'Collapse key', // required\n        'data.key1': 'value1',\n        'data.key2': 'value2',\n        delay_while_idle: '1' // remove if not needed\n    };\n    \n    c2dm.send(message, function(err, messageId){\n        if (err) {\n            console.log(\"Something has gone wrong!\");\n        } else {\n            console.log(\"Sent with message ID: \", messageId);\n        }\n    });\n\n### Avoiding login procedure\nYou can avoid the login procedure by manually setting Google ClientLogin Auth token in the connection config.\nFirst of all you need to fetch the token by executing the following command. Replace `ROLE_EMAIL`, `ROLE_PASSWORDPASS` and `YOURCOMPANY-YOURAPP-Version` with your data:\n\n    $ curl -X POST https://www.google.com/accounts/ClientLogin -d Email=ROLE_EMAIL -d Passwd=ROLE_PASSWORDPASS -d accountType=HOSTED_OR_GOOGLE -d service=ac2dm -d source=YOURCOMPANY-YOURAPP-Version\t\n\nYou will receive three lines. Skip `SID` and `LSID` and copy line starting with `Auth=`. Next include 'token' property into config data and fill it with this `Auth=...` line:\n\n    var config = {\n        token: 'Auth=VVVVEEERY-HUDE-TOKEN',  // N.B. include with Auth= prefix\n    };\n    var c2dm = new C2DM(config);\n\nHowever, Google will occaisionally require the token to be updated before further requests can be accepted. If this happens, the `Update-Client-Auth` header will automatically be used to update the current configurations token, but obviously will not be stored on the next reload. A `token` event will be triggered if this happens so you can update a local configuration file, but its probably easier to perform a login each time the application is started:\n\n    c2dm.on('token', function(err, token) {\n      // Do something with the new token\n    });\n\n### Testing sending a message\nIf it looks like things aren't going your way, try sending a request manually using the following curl command and see what google sends back to you:\n\n    $ curl -H \"Authorization: GoogleLogin auth=YOUR-LONG-TOKEN\" -X POST https://android.apis.google.com/c2dm/send -d \"registration_id=DESTINATION-TOKEN\" -d \"collapse_key=key\" -d \"data.event=hire\" -v\n\nYou should get back the header details along with a message id if sending has been successful. For example:\n\n    .... sending headers and SSL stuff .....\n    < HTTP/1.1 200 OK\n    < Content-Type: text/plain\n    < Date: Wed, 18 Jan 2012 11:18:01 GMT\n    < Expires: Wed, 18 Jan 2012 11:18:01 GMT\n    < Cache-Control: private, max-age=0\n    < X-Content-Type-Options: nosniff\n    < X-Frame-Options: SAMEORIGIN\n    < X-XSS-Protection: 1; mode=block\n    < Server: GSE\n    < Transfer-Encoding: chunked\n    <\n    id=0:1326885481081626%900b347100019e5f\n    .... more SSL stuff ....\n\n### Keep-alive connection\nThis module supports Connection: keep-alive header too keep connection to c2dm gate established. You could use it by simply including property in config:\n\n    var config = {\n        ...\n        keepAlive: true,  // it is false by default\n    };\n\n\n## Credits\n\nWritten and maintained by [Yury Proshchenko][5].\n\n## License\n\nThe MIT License\n\nCopyright (c) 2011 Yury Proshchenko (spect.man@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[1]: http://code.google.com/android/c2dm/index.html\n[2]: http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#Request\n[3]: http://code.google.com/android/c2dm/index.html#push\n[4]: http://github.com/isaacs/npm\n[5]: mailto:spect.man@gmail.com\n\n## Changelog\n\n1.1.0\n\n - [#2](http://github.com/SpeCT/node-c2dm/issues/2) – Exponential backoff retry on quota and temporary errors (thanks Olivier Poitrey aka [rs](https://github.com/rs))\n - Handle auth_token refresh (Update-Client-Auth header) (thanks [Sam Lown](https://github.com/samlown))\n\n1.0.4\n\n  - Handle scenario where 'close' event is emitted before 'end' event (node 0.4.x)\n\n1.0.3\n\n  - Converted internal subscription method from on(2) to once(2)\n  - Published to npm\n\n1.0.2\n\n  - Fixed 'Content-length missing' error\n\n1.0.1\n\n  - Fixed package.json (thanks Mohd Faruq aka ruqqq)\n  - Fixed 'socked hang up' error (once again thanks Mohd Faruq aka ruqqq)\n\n1.0.0:\n\n  - Initial release","maintainers":[{"name":"spect","email":"spect.man@gmail.com"}],"directories":{}},"1.2.0":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.2.0","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},{"name":"Mohd Faruq","url":"https://github.com/ruqqq"},{"name":"Sam Lown","url":"https://github.com/samlown"},{"name":"Olivier Poitrey","url":"https://github.com/rs"},{"name":"Charles Daniel","url":"https://github.com/charlesdaniel"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"http://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"dependencies":{"retry":">=0.6.0"},"readme":"# node-c2dm\nAn interface for [Android Cloud to Device Messaging][1] push notification service for Node.js\n\n## Installation\n\nVia [npm][4]:\n\n    $ npm install c2dm\n\nAs a submodule of your project\n\n    $ git submodule add http://github.com/SpeCT/node-c2dm.git c2dm\n    $ git submodule update --init\n\n## Usage\n### Load in the module\n\n    var C2DM = require('c2dm').C2DM;\n\n### Create a connection\nSee [Google Client Login documentation][2] for details.\n\n    var config = {\n        user: 'bla-blah-blah@gmail.com',\n        password: 'your-huge-very-very-strong-password',\n        source: 'com.company.app-name',\n    };\n    var c2dm = new C2DM(config);\n\n### Login into c2dm\n\n    c2dm.login(function(err, token){\n        // err - error, received from Google ClientLogin api\n        // token - Auth token\n    });\n\n### Send message to device\nSee [C2DM documentation][3] for details.\n\n    var message = {\n        registration_id: 'Device registration id',\n        collapse_key: 'Collapse key', // required\n        'data.key1': 'value1',\n        'data.key2': 'value2',\n        delay_while_idle: '1' // remove if not needed\n    };\n\n    c2dm.send(message, function(err, messageId){\n        if (err) {\n            console.log(\"Something has gone wrong!\");\n        } else {\n            console.log(\"Sent with message ID: \", messageId);\n        }\n    });\n\n### Avoiding login procedure\nYou can avoid the login procedure by manually setting Google ClientLogin Auth token in the connection config.\nFirst of all you need to fetch the token by executing the following command. Replace `ROLE_EMAIL`, `ROLE_PASSWORDPASS` and `YOURCOMPANY-YOURAPP-Version` with your data:\n\n    $ curl -X POST https://www.google.com/accounts/ClientLogin -d Email=ROLE_EMAIL -d Passwd=ROLE_PASSWORDPASS -d accountType=HOSTED_OR_GOOGLE -d service=ac2dm -d source=YOURCOMPANY-YOURAPP-Version\n\nYou will receive three lines. Skip `SID` and `LSID` and copy line starting with `Auth=`. Next include 'token' property into config data and fill it with this `Auth=...` line:\n\n    var config = {\n        token: 'Auth=VVVVEEERY-HUDE-TOKEN',  // N.B. include with Auth= prefix\n    };\n    var c2dm = new C2DM(config);\n\nHowever, Google will occaisionally require the token to be updated before further requests can be accepted. If this happens, the `Update-Client-Auth` header will automatically be used to update the current configurations token, but obviously will not be stored on the next reload. A `token` event will be triggered if this happens so you can update a local configuration file, but its probably easier to perform a login each time the application is started:\n\n    c2dm.on('token', function(err, token) {\n      // Do something with the new token\n    });\n\n### Testing sending a message\nIf it looks like things aren't going your way, try sending a request manually using the following curl command and see what google sends back to you:\n\n    $ curl -H \"Authorization: GoogleLogin auth=YOUR-LONG-TOKEN\" -X POST https://android.apis.google.com/c2dm/send -d \"registration_id=DESTINATION-TOKEN\" -d \"collapse_key=key\" -d \"data.event=hire\" -v\n\nYou should get back the header details along with a message id if sending has been successful. For example:\n\n    .... sending headers and SSL stuff .....\n    < HTTP/1.1 200 OK\n    < Content-Type: text/plain\n    < Date: Wed, 18 Jan 2012 11:18:01 GMT\n    < Expires: Wed, 18 Jan 2012 11:18:01 GMT\n    < Cache-Control: private, max-age=0\n    < X-Content-Type-Options: nosniff\n    < X-Frame-Options: SAMEORIGIN\n    < X-XSS-Protection: 1; mode=block\n    < Server: GSE\n    < Transfer-Encoding: chunked\n    <\n    id=0:1326885481081626%900b347100019e5f\n    .... more SSL stuff ....\n\n### Keep-alive connection\nThis module supports Connection: keep-alive header too keep connection to c2dm gate established. You could use it by simply including property in config:\n\n    var config = {\n        ...\n        keepAlive: true,  // it is false by default\n    };\n\n\n## Credits\nWritten and maintained by [Yury Proshchenko][5].\n\n## Contributors\n\n* Mohd Faruq aka [ruqqq][6]\n* [Sam Lown][7]\n* Olivier Poitrey aka [rs][8]\n* [Charles Daniel][9]\n\n\n## License\n\nThe MIT License\n\nCopyright (c) 2011 Yury Proshchenko (spect.man@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n## Changelog\n\n1.2.0\n\n - [#16](http://github.com/SpeCT/node-c2dm/issues/16), [#19](http://github.com/SpeCT/node-c2dm/issues/19), [#2](http://github.com/SpeCT/node-c2dm/issues/22) – Missed `Auth=` prefix was restored by [Charles Daniel][9]\n\n1.1.0\n\n - [#2](http://github.com/SpeCT/node-c2dm/issues/2) – Exponential backoff retry on quota and temporary errors (thanks Olivier Poitrey aka [rs][8])\n - Handle auth_token refresh (Update-Client-Auth header) (thanks [Sam Lown][7])\n\n1.0.4\n\n  - Handle scenario where 'close' event is emitted before 'end' event (node 0.4.x)\n\n1.0.3\n\n  - Converted internal subscription method from on(2) to once(2)\n  - Published to npm\n\n1.0.2\n\n  - Fixed 'Content-length missing' error\n\n1.0.1\n\n  - Fixed package.json (thanks Mohd Faruq aka [ruqqq][6])\n  - Fixed 'socked hang up' error (once again thanks Mohd Faruq aka [ruqqq][6])\n\n1.0.0:\n\n  - Initial release\n\n\n[1]: http://code.google.com/android/c2dm/index.html\n[2]: http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#Request\n[3]: http://code.google.com/android/c2dm/index.html#push\n[4]: http://github.com/isaacs/npm\n[5]: mailto:spect.man@gmail.com\n[6]: https://github.com/ruqqq\n[7]: https://github.com/samlown\n[8]: https://github.com/rs\n[9]: https://github.com/charlesdaniel\n","_id":"c2dm@1.2.0","dist":{"shasum":"3d1b7295da5838b3dfe13919b51a13d5bb2fdeb7","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.2.0.tgz","integrity":"sha512-ScmlQN18UuTRhxi5YGc3UJiJwqDYUrIhmmbe/1xeIaKEAvDHWp+1c2/JcVZSiHvkAsCtXJTd/HNnIrXmblagHQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAHGZ/e66KlLHLhmnBjyohl16AuUcEjy129jBj8jgn5jAiEAlIPEyWy//wbX6xNuvS2lcPTQzudf3HOJBQbSKeKgs+c="}]},"_npmVersion":"1.1.58","_npmUser":{"name":"spect","email":"spect.man@gmail.com"},"maintainers":[{"name":"spect","email":"spect.man@gmail.com"}]},"1.2.1":{"name":"c2dm","description":"An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js","version":"1.2.1","author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"contributors":[{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},{"name":"Mohd Faruq","url":"https://github.com/ruqqq"},{"name":"Sam Lown","url":"https://github.com/samlown"},{"name":"Olivier Poitrey","url":"https://github.com/rs"},{"name":"Charles Daniel","url":"https://github.com/charlesdaniel"}],"keywords":["google","push","push notifications","android","c2dm"],"main":"./lib/c2dm.js","repository":{"type":"git","url":"http://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"engines":{"node":">= 0.2.0"},"dependencies":{"retry":">=0.6.0"},"readme":"# node-c2dm\nAn interface for [Android Cloud to Device Messaging][1] push notification service for Node.js\n\n## Installation\n\nVia [npm][4]:\n\n    $ npm install c2dm\n\nAs a submodule of your project\n\n    $ git submodule add http://github.com/SpeCT/node-c2dm.git c2dm\n    $ git submodule update --init\n\n## Usage\n### Load in the module\n\n    var C2DM = require('c2dm').C2DM;\n\n### Create a connection\nSee [Google Client Login documentation][2] for details.\n\n    var config = {\n        user: 'bla-blah-blah@gmail.com',\n        password: 'your-huge-very-very-strong-password',\n        source: 'com.company.app-name',\n    };\n    var c2dm = new C2DM(config);\n\n### Login into c2dm\n\n    c2dm.login(function(err, token){\n        // err - error, received from Google ClientLogin api\n        // token - Auth token\n    });\n\n### Send message to device\nSee [C2DM documentation][3] for details.\n\n    var message = {\n        registration_id: 'Device registration id',\n        collapse_key: 'Collapse key', // required\n        'data.key1': 'value1',\n        'data.key2': 'value2',\n        delay_while_idle: '1' // remove if not needed\n    };\n\n    c2dm.send(message, function(err, messageId){\n        if (err) {\n            console.log(\"Something has gone wrong!\");\n        } else {\n            console.log(\"Sent with message ID: \", messageId);\n        }\n    });\n\n### Avoiding login procedure\nYou can avoid the login procedure by manually setting Google ClientLogin Auth token in the connection config.\nFirst of all you need to fetch the token by executing the following command. Replace `ROLE_EMAIL`, `ROLE_PASSWORDPASS` and `YOURCOMPANY-YOURAPP-Version` with your data:\n\n    $ curl -X POST https://www.google.com/accounts/ClientLogin -d Email=ROLE_EMAIL -d Passwd=ROLE_PASSWORDPASS -d accountType=HOSTED_OR_GOOGLE -d service=ac2dm -d source=YOURCOMPANY-YOURAPP-Version\n\nYou will receive three lines. Skip `SID` and `LSID` and copy line starting with `Auth=`. Next include 'token' property into config data and fill it with this `Auth=...` line:\n\n    var config = {\n        token: 'Auth=VVVVEEERY-HUDE-TOKEN',  // N.B. include with Auth= prefix\n    };\n    var c2dm = new C2DM(config);\n\nHowever, Google will occaisionally require the token to be updated before further requests can be accepted. If this happens, the `Update-Client-Auth` header will automatically be used to update the current configurations token, but obviously will not be stored on the next reload. A `token` event will be triggered if this happens so you can update a local configuration file, but its probably easier to perform a login each time the application is started:\n\n    c2dm.on('token', function(err, token) {\n      // Do something with the new token\n    });\n\n### Testing sending a message\nIf it looks like things aren't going your way, try sending a request manually using the following curl command and see what google sends back to you:\n\n    $ curl -H \"Authorization: GoogleLogin auth=YOUR-LONG-TOKEN\" -X POST https://android.apis.google.com/c2dm/send -d \"registration_id=DESTINATION-TOKEN\" -d \"collapse_key=key\" -d \"data.event=hire\" -v\n\nYou should get back the header details along with a message id if sending has been successful. For example:\n\n    .... sending headers and SSL stuff .....\n    < HTTP/1.1 200 OK\n    < Content-Type: text/plain\n    < Date: Wed, 18 Jan 2012 11:18:01 GMT\n    < Expires: Wed, 18 Jan 2012 11:18:01 GMT\n    < Cache-Control: private, max-age=0\n    < X-Content-Type-Options: nosniff\n    < X-Frame-Options: SAMEORIGIN\n    < X-XSS-Protection: 1; mode=block\n    < Server: GSE\n    < Transfer-Encoding: chunked\n    <\n    id=0:1326885481081626%900b347100019e5f\n    .... more SSL stuff ....\n\n### Keep-alive connection\nThis module supports Connection: keep-alive header too keep connection to c2dm gate established. You could use it by simply including property in config:\n\n    var config = {\n        ...\n        keepAlive: true,  // it is false by default\n    };\n\n\n## Credits\nWritten and maintained by [Yury Proshchenko][5].\n\n## Contributors\n\n* Mohd Faruq aka [ruqqq][6]\n* [Sam Lown][7]\n* Olivier Poitrey aka [rs][8]\n* [Charles Daniel][9]\n\n\n## License\n\nThe MIT License\n\nCopyright (c) 2011 Yury Proshchenko (spect.man@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n## Changelog\n\n1.2.0\n\n - [#16](http://github.com/SpeCT/node-c2dm/issues/16), [#19](http://github.com/SpeCT/node-c2dm/issues/19), [#2](http://github.com/SpeCT/node-c2dm/issues/22) – Missed `Auth=` prefix was restored by [Charles Daniel][9]\n\n1.1.0\n\n - [#2](http://github.com/SpeCT/node-c2dm/issues/2) – Exponential backoff retry on quota and temporary errors (thanks Olivier Poitrey aka [rs][8])\n - Handle auth_token refresh (Update-Client-Auth header) (thanks [Sam Lown][7])\n\n1.0.4\n\n  - Handle scenario where 'close' event is emitted before 'end' event (node 0.4.x)\n\n1.0.3\n\n  - Converted internal subscription method from on(2) to once(2)\n  - Published to npm\n\n1.0.2\n\n  - Fixed 'Content-length missing' error\n\n1.0.1\n\n  - Fixed package.json (thanks Mohd Faruq aka [ruqqq][6])\n  - Fixed 'socked hang up' error (once again thanks Mohd Faruq aka [ruqqq][6])\n\n1.0.0:\n\n  - Initial release\n\n\n[1]: http://code.google.com/android/c2dm/index.html\n[2]: http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#Request\n[3]: http://code.google.com/android/c2dm/index.html#push\n[4]: http://github.com/isaacs/npm\n[5]: mailto:spect.man@gmail.com\n[6]: https://github.com/ruqqq\n[7]: https://github.com/samlown\n[8]: https://github.com/rs\n[9]: https://github.com/charlesdaniel\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/SpeCT/node-c2dm/issues"},"_id":"c2dm@1.2.1","dist":{"shasum":"ccc0346bee0baa499e0fedd3dd3025b2d65002e6","tarball":"https://registry.npmjs.org/c2dm/-/c2dm-1.2.1.tgz","integrity":"sha512-JvweUKNYKineptV5BcuSfJOnrULeHbuBe12rTLF11e9E/pHjc8UYiZZei8l8uMqC1LMNjW65ru+xOmLAWFRZOw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuU9ClOjwJ9DUZv4z+0kpYc4dV45vdKmJSiBZHRGUtgwIhAPQExFlQHJFjA1AOtmmnqHW/mHAfO0t2r3FVQ6O6Bn9x"}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"spect","email":"spect.man@gmail.com"},"maintainers":[{"name":"spect","email":"spect.man@gmail.com"}]}},"maintainers":[{"name":"spect","email":"spect.man@gmail.com"}],"time":{"modified":"2022-06-13T05:22:22.342Z","created":"2011-01-28T14:33:36.938Z","1.0.0":"2011-01-28T14:33:37.656Z","1.0.1":"2011-04-29T08:11:59.307Z","1.0.2":"2011-05-05T00:42:56.174Z","1.0.3":"2011-08-15T19:08:13.856Z","1.0.4":"2012-03-18T13:56:01.028Z","1.1.0":"2012-04-13T17:08:48.527Z","1.2.0":"2012-10-27T09:03:45.916Z","1.2.1":"2013-06-27T11:37:14.355Z"},"author":{"name":"Yury Proshchenko","email":"spect.man@gmail.com"},"repository":{"type":"git","url":"http://github.com/SpeCT/node-c2dm.git","web":"http://github.com/SpeCT/node-c2dm"},"users":{"rchk":true}}