
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
An interface for Android Cloud to Device Messaging push notification service for Node.js
Via npm:
$ npm install c2dm
As a submodule of your project
$ git submodule add http://github.com/SpeCT/node-c2dm.git c2dm
$ git submodule update --init
var C2DM = require('c2dm').C2DM;
See Google Client Login documentation for details.
var config = {
user: 'bla-blah-blah@gmail.com',
password: 'your-huge-very-very-strong-password',
source: 'com.company.app-name',
};
var c2dm = new C2DM(config);
c2dm.login(function(err, token){
// err - error, received from Google ClientLogin api
// token - Auth token
});
See C2DM documentation for details.
var message = {
registration_id: 'Device registration id',
collapse_key: 'Collapse key', // required
'data.key1': 'value1',
'data.key2': 'value2',
delay_while_idle: '1' // remove if not needed
};
c2dm.send(message, function(err, messageId){
if (err) {
console.log("Something has gone wrong!");
} else {
console.log("Sent with message ID: ", messageId);
}
});
You can avoid the login procedure by manually setting Google ClientLogin Auth token in the connection config.
First 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:
$ 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
You 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:
var config = {
token: 'Auth=VVVVEEERY-HUDE-TOKEN', // N.B. include with Auth= prefix
};
var c2dm = new C2DM(config);
However, 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:
c2dm.on('token', function(err, token) {
// Do something with the new token
});
If 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:
$ 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
You should get back the header details along with a message id if sending has been successful. For example:
.... sending headers and SSL stuff .....
< HTTP/1.1 200 OK
< Content-Type: text/plain
< Date: Wed, 18 Jan 2012 11:18:01 GMT
< Expires: Wed, 18 Jan 2012 11:18:01 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Transfer-Encoding: chunked
<
id=0:1326885481081626%900b347100019e5f
.... more SSL stuff ....
This module supports Connection: keep-alive header too keep connection to c2dm gate established. You could use it by simply including property in config:
var config = {
...
keepAlive: true, // it is false by default
};
Written and maintained by Yury Proshchenko.
The MIT License
Copyright (c) 2011 Yury Proshchenko (spect.man@gmail.com)
Permission 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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE 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.
1.2.0
Auth=
prefix was restored by Charles Daniel1.1.0
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0:
FAQs
An interface to the Android Cloud to Device Messaging (C2DM) service for Node.js
The npm package c2dm receives a total of 63 weekly downloads. As such, c2dm popularity was classified as not popular.
We found that c2dm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.