فهرست منبع

Updated pusher

CauseFX 6 سال پیش
والد
کامیت
d8fbfbfa98

+ 6 - 6
api/composer.lock

@@ -1235,16 +1235,16 @@
         },
         {
             "name": "pusher/pusher-php-server",
-            "version": "v3.2.0",
+            "version": "v3.3.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/pusher/pusher-http-php.git",
-                "reference": "4da4d208fe13fd2ff71ede5063a3456f23f38cf7"
+                "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/4da4d208fe13fd2ff71ede5063a3456f23f38cf7",
-                "reference": "4da4d208fe13fd2ff71ede5063a3456f23f38cf7",
+                "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
+                "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
                 "shasum": ""
             },
             "require": {
@@ -1254,7 +1254,7 @@
                 "psr/log": "^1.0"
             },
             "require-dev": {
-                "phpunit/phpunit": "^4.8 || ^5.7"
+                "phpunit/phpunit": "^4.8.35 || ^5.7"
             },
             "type": "library",
             "extra": {
@@ -1285,7 +1285,7 @@
                 "rest",
                 "trigger"
             ],
-            "time": "2018-08-13T14:57:32+00:00"
+            "time": "2019-01-18T12:10:21+00:00"
         },
         {
             "name": "rmccue/requests",

+ 7 - 7
api/vendor/composer/installed.json

@@ -1274,17 +1274,17 @@
     },
     {
         "name": "pusher/pusher-php-server",
-        "version": "v3.2.0",
-        "version_normalized": "3.2.0.0",
+        "version": "v3.3.1",
+        "version_normalized": "3.3.1.0",
         "source": {
             "type": "git",
             "url": "https://github.com/pusher/pusher-http-php.git",
-            "reference": "4da4d208fe13fd2ff71ede5063a3456f23f38cf7"
+            "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/4da4d208fe13fd2ff71ede5063a3456f23f38cf7",
-            "reference": "4da4d208fe13fd2ff71ede5063a3456f23f38cf7",
+            "url": "https://api.github.com/repos/pusher/pusher-http-php/zipball/2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
+            "reference": "2279bcd21a608a76f9be1fe0675aa2dd1efb2fa0",
             "shasum": ""
         },
         "require": {
@@ -1294,9 +1294,9 @@
             "psr/log": "^1.0"
         },
         "require-dev": {
-            "phpunit/phpunit": "^4.8 || ^5.7"
+            "phpunit/phpunit": "^4.8.35 || ^5.7"
         },
-        "time": "2018-08-13T14:57:32+00:00",
+        "time": "2019-01-18T12:10:21+00:00",
         "type": "library",
         "extra": {
             "branch-alias": {

+ 9 - 0
api/vendor/pusher/pusher-php-server/CHANGELOG.md

@@ -1,3 +1,12 @@
+## 3.3.1 (2019-01-18)
+
+[FIXED] PHP Notice for Undefined `socket_id` in triggerBatch
+
+## 3.3.0 (2019-01-03)
+
+[ADDED] Support for End-to-end encrypted channels for triggerbatch
+[FIXED] trigger behavior with mixtures of encrypted and non-encrypted channels
+
 ## 3.2.0 (2018-08-13)
 
 [ADDED] This release adds support for end to end encrypted channels, a new feature for Channels. Read more [in our docs](https://pusher.com/docs/client_api_guide/client_encrypted_channels).

+ 1 - 1
api/vendor/pusher/pusher-php-server/composer.json

@@ -10,7 +10,7 @@
         "paragonie/sodium_compat": "^1.6"
     },
     "require-dev": {
-        "phpunit/phpunit": "^4.8 || ^5.7"
+        "phpunit/phpunit": "^4.8.35 || ^5.7"
     },
     "autoload": {
         "psr-4": {

+ 56 - 28
api/vendor/pusher/pusher-php-server/src/Pusher.php

@@ -14,7 +14,7 @@ class Pusher implements LoggerAwareInterface
     /**
      * @var string Version
      */
-    public static $VERSION = '3.2.0';
+    public static $VERSION = '3.3.1';
 
     /**
      * @var null|PusherCrypto
@@ -55,6 +55,9 @@ class Pusher implements LoggerAwareInterface
      *                         useTLS - quick option to use scheme of https and port 443.
      *                         encrypted - deprecated; renamed to `useTLS`.
      *                         cluster - cluster name to connect to.
+     *                         encryption_master_key - a 32 char long key. This key, along with the channel name, are used to derive per-channel encryption keys. Per-channel keys are used encrypt event data on encrypted channels.
+     *                         debug - (default `false`) if `true`, every `trigger()` and `triggerBatch()` call will return a `$response` object, useful for logging/inspection purposes.
+     *                         curl_options - wrapper for curl_setopt, more here: http://php.net/manual/en/function.curl-setopt.php
      *                         notification_host - host to connect to for native notifications.
      *                         notification_scheme - scheme for the notification_host.
      * @param string $host     [optional] - deprecated
@@ -373,8 +376,12 @@ class Pusher implements LoggerAwareInterface
         $response['body'] = curl_exec($ch);
         $response['status'] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
 
-        if ($response['body'] === false || $response['status'] < 200 || 400 <= $response['status']) {
+        if ($response['body'] === false) {
             $this->log('exec_curl error: {error}', array('error' => curl_error($ch)), LogLevel::ERROR);
+        } elseif ($response['status'] < 200 || 400 <= $response['status']) {
+            $this->log('exec_curl {status} error from server: {body}', $response, LogLevel::ERROR);
+        } else {
+            $this->log('exec_curl {status} response: {body}', $response);
         }
 
         $this->log('exec_curl response: {response}', array('response' => print_r($response, true)));
@@ -393,11 +400,11 @@ class Pusher implements LoggerAwareInterface
     }
 
     /**
-     * Build the ddn domain.
+     * Build the Channels domain.
      *
      * @return string
      */
-    private function ddn_domain()
+    private function channels_domain()
     {
         return $this->settings['scheme'].'://'.$this->settings['host'].':'.$this->settings['port'];
     }
@@ -490,21 +497,35 @@ class Pusher implements LoggerAwareInterface
         $this->validate_channels($channels);
         $this->validate_socket_id($socket_id);
 
+        $has_encrypted_channel = false;
+        foreach ($channels as $chan) {
+            if (PusherCrypto::is_encrypted_channel($chan)) {
+                $has_encrypted_channel = true;
+            }
+        }
+
+        if ($has_encrypted_channel) {
+            if (count($channels) > 1) {
+                // For rationale, see limitations of end-to-end encryption in the README
+                throw new PusherException('You cannot trigger to multiple channels when using encrypted channels');
+            } else {
+                $data_encoded = $this->crypto->encrypt_payload($channels[0], $already_encoded ? $data : json_encode($data));
+            }
+        } else {
+            $data_encoded = $already_encoded ? $data : json_encode($data);
+        }
+
         $query_params = array();
 
         $s_url = $this->settings['base_path'].'/events';
 
-        $data_encoded = $already_encoded ? $data : json_encode($data);
-
         // json_encode might return false on failure
         if (!$data_encoded) {
             $this->log('Failed to perform json_encode on the the provided data: {error}', array(
                 'error' => print_r($data, true),
             ), LogLevel::ERROR);
         }
-        if (PusherCrypto::is_encrypted_channel($channels[0])) {
-            $data_encoded = $this->crypto->encrypt_payload($channels[0], $data_encoded);
-        }
+
         $post_params = array();
         $post_params['name'] = $event;
         $post_params['data'] = $data_encoded;
@@ -518,7 +539,7 @@ class Pusher implements LoggerAwareInterface
 
         $query_params['body_md5'] = md5($post_value);
 
-        $ch = $this->create_curl($this->ddn_domain(), $s_url, 'POST', $query_params);
+        $ch = $this->create_curl($this->channels_domain(), $s_url, 'POST', $query_params);
 
         $this->log('trigger POST: {post_value}', compact('post_value'));
 
@@ -526,14 +547,14 @@ class Pusher implements LoggerAwareInterface
 
         $response = $this->exec_curl($ch);
 
-        if ($response['status'] === 200 && $debug === false) {
-            return true;
-        }
-
         if ($debug === true || $this->settings['debug'] === true) {
             return $response;
         }
 
+        if ($response['status'] === 200) {
+            return true;
+        }
+
         return false;
     }
 
@@ -550,26 +571,33 @@ class Pusher implements LoggerAwareInterface
      */
     public function triggerBatch($batch = array(), $debug = false, $already_encoded = false)
     {
-        $query_params = array();
+        foreach ($batch as $key => $event) {
+            $this->validate_channel($event['channel']);
+            if (isset($event['socket_id'])) {
+                $this->validate_socket_id($event['socket_id']);
+            }
 
-        $s_url = $this->settings['base_path'].'/batch_events';
+            $data = $event['data'];
+            if (!is_string($data)) {
+                $data = $already_encoded ? $data : json_encode($data);
+            }
 
-        if (!$already_encoded) {
-            foreach ($batch as $key => $event) {
-                if (!is_string($event['data'])) {
-                    $batch[$key]['data'] = json_encode($event['data']);
-                }
+            if (PusherCrypto::is_encrypted_channel($event['channel'])) {
+                $batch[$key]['data'] = $this->crypto->encrypt_payload($event['channel'], $data);
+            } else {
+                $batch[$key]['data'] = $data;
             }
         }
 
         $post_params = array();
         $post_params['batch'] = $batch;
-
         $post_value = json_encode($post_params);
 
+        $query_params = array();
         $query_params['body_md5'] = md5($post_value);
+        $s_url = $this->settings['base_path'].'/batch_events';
 
-        $ch = $this->create_curl($this->ddn_domain(), $s_url, 'POST', $query_params);
+        $ch = $this->create_curl($this->channels_domain(), $s_url, 'POST', $query_params);
 
         $this->log('trigger POST: {post_value}', compact('post_value'));
 
@@ -577,14 +605,14 @@ class Pusher implements LoggerAwareInterface
 
         $response = $this->exec_curl($ch);
 
-        if ($response['status'] === 200 && $debug === false) {
-            return true;
-        }
-
         if ($debug === true || $this->settings['debug'] === true) {
             return $response;
         }
 
+        if ($response['status'] === 200) {
+            return true;
+        }
+
         return false;
     }
 
@@ -649,7 +677,7 @@ class Pusher implements LoggerAwareInterface
     {
         $s_url = $this->settings['base_path'].$path;
 
-        $ch = $this->create_curl($this->ddn_domain(), $s_url, 'GET', $params);
+        $ch = $this->create_curl($this->channels_domain(), $s_url, 'GET', $params);
 
         $response = $this->exec_curl($ch);