Comments (4)
Yes, it should be pretty easy to encrypt the payload before it is sent based on some optional parameters.
If you'd like to take a stab at implementing it, I'd be happy to review and provide some feedback for a pull request.
from php-gcm.
Hello @lkorth, we have implemented some properties on the Message class (publicKey, salt, rawData) with getters and setters.
We have then modified the Sender to intercept those properties (only if set) and add appropriate headers:
Encryption: salt=<SALT>
Crypto-Key: dh=<PUBLICKEY>
Content-Encoding: aesgcm
and body field for the notification request (as explained here):
{
"registration_ids": [ "…" ],
"raw_data": "BIXzEKOFquzVlr/1tS1bhmobZ…"
}
This way your library can be used to send encrypted messages without having to encrypt them: is up to the user to give a correct rawData content.
Here an example:
$message = new Message();
$message->publicKey($publicKey);
$message->salt($salt);
$message->rawData(base64_encode($encryptedPayload));
If you are interested we'll make a pull request. At the moment we have implemented it above your latest stable release but it's not hard to port it to the developer one.
from php-gcm.
If you'd like to make a PR with those changes, that would be awesome! If you're already encrypting the data, would you consider adding a method to the Message
class for encrypting data? When it builds the message, if the public key and salt are present it could just encrypt it for you.
A few things have moved around in the Sender
class, but it should be trivial to update to include the headers. The only other change that I see off hand is just making the functions on Message
chainable.
Let me know if I can clarify anything, otherwise I look forward to reviewing the PR.
from php-gcm.
We will create the PR as soon as possible. Unfortunately the encryption stuff is really complex and we are using code from an external library (WebPush) that depends from many other libraries.
So we have decided to decouple the payload handling stuff from the encryption tasks to ease the PR. Please take a look at their code, maybe you can use it to implement the same stuff in your library in future.
from php-gcm.
Related Issues (20)
- Google Cloud Messaging (GCM) Notification receiving with logs detail HOT 2
- GCM Group Notifications HOT 4
- Should be able to specify curl cainfo cert path HOT 1
- how to set notification payload? HOT 6
- Add support for sending topic messages HOT 1
- Simultaneous sending limit HOT 4
- wrong $retries variable HOT 1
- Composer installs old version HOT 8
- Release 1.1.1 has outdated end point HOT 1
- Put a release onto composer? HOT 1
- Complex data in push message HOT 1
- How can I send Big Picture Style notification with this? HOT 1
- Support for Firebase Cloud Messaging (FCM) HOT 1
- I have a question about php-gcm. HOT 1
- Example usage
- please update readme code base has changed
- About your class
- Firebase server sends old messages
- Migration to FCM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-gcm.