Giter Club home page Giter Club logo

Comments (4)

lkorth avatar lkorth commented on July 21, 2024

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.

delitestudio avatar delitestudio commented on July 21, 2024

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.

lkorth avatar lkorth commented on July 21, 2024

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.

delitestudio avatar delitestudio commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.