From 46e58afdc6b5a687edaae7f8f647788984a120c6 Mon Sep 17 00:00:00 2001 From: Gary Hockin Date: Fri, 16 Aug 2019 08:53:46 +0100 Subject: [PATCH 01/14] Added composer.lock to prevent broken Dotenv docs --- composer.lock | 133 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 124 insertions(+), 9 deletions(-) diff --git a/composer.lock b/composer.lock index 50714d2..e11eba9 100644 --- a/composer.lock +++ b/composer.lock @@ -1,11 +1,119 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], "content-hash": "0cc1742d0846f4fd1089fd678bf269ef", "packages": [ + { + "name": "phpoption/phpoption", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/php-option.git", + "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed", + "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.7.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-0": { + "PhpOption\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Option Type for PHP", + "keywords": [ + "language", + "option", + "php", + "type" + ], + "time": "2015-07-25T16:39:46+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.12-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com/", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-08-06T08:03:45+00:00" + }, { "name": "twilio/sdk", "version": "5.22.0", @@ -58,24 +166,26 @@ "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "54d599d414f8cf3f6129e287acaf44b610486aa1" + "reference": "9159290ad347bf56fa6d208bf35645c450f9e567" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/54d599d414f8cf3f6129e287acaf44b610486aa1", - "reference": "54d599d414f8cf3f6129e287acaf44b610486aa1", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/9159290ad347bf56fa6d208bf35645c450f9e567", + "reference": "9159290ad347bf56fa6d208bf35645c450f9e567", "shasum": "" }, "require": { - "php": ">=5.3.9" + "php": "^5.4 || ^7.0", + "phpoption/phpoption": "^1.5", + "symfony/polyfill-ctype": "^1.9" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.0" + "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -88,10 +198,15 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "homepage": "https://gjcampbell.co.uk/" + }, { "name": "Vance Lucas", "email": "vance@vancelucas.com", - "homepage": "http://www.vancelucas.com/" + "homepage": "https://vancelucas.com/" } ], "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", @@ -100,7 +215,7 @@ "env", "environment" ], - "time": "2018-08-22 19:34:05" + "time": "2019-06-29T14:13:05+00:00" } ], "packages-dev": [], From baedbf761776271db9b1a9abcb82519f2cf84052 Mon Sep 17 00:00:00 2001 From: Gary Hockin Date: Fri, 16 Aug 2019 08:55:57 +0100 Subject: [PATCH 02/14] Removed warning from README, it's fixed in previous commit --- README.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.md b/README.md index ae43191..ce67542 100644 --- a/README.md +++ b/README.md @@ -87,15 +87,6 @@ Your application should now be running at [http://localhost:8000/](http://localh Check your config values, and follow the links to the demo applications! -## Warning: You may need to update the phpdotenv dependency - -The phpdotenv dependency (for loading configuration information) was recently updated, so you may need to run composer update on your directory if you have downloaded this project in the past. For new installations, this step won't be necessary. The error you will get is: - -``` -/config-check.php - Uncaught Error: Call to undefined method Dotenv\Dotenv::create() -``` - - ## Running the SDK Starter Kit with ngrok If you are going to connect to this SDK Starter Kit with a mobile app (and you should try it out!), your phone won't be able to access localhost directly. You'll need to create a publicly accessible URL using a tool like [ngrok](https://ngrok.com/) to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token. From 530f8eec1ae5d1779992e68dd474552a2bc28c7d Mon Sep 17 00:00:00 2001 From: Gary Hockin Date: Tue, 27 Aug 2019 10:42:56 +0100 Subject: [PATCH 03/14] Updated README added back composer update instruction --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index ce67542..ff3d67d 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,14 @@ Your application should now be running at [http://localhost:8000/](http://localh Check your config values, and follow the links to the demo applications! +## Warning: You may need to update the phpdotenv dependency + +The phpdotenv dependency (for loading configuration information) was recently updated, so you may need to run `composer update` on your project if you have downloaded this project in the past. For new installations, this step won't be necessary. The error you will get is: + +``` +/config-check.php - Uncaught Error: Call to undefined method Dotenv\Dotenv::create() +``` + ## Running the SDK Starter Kit with ngrok If you are going to connect to this SDK Starter Kit with a mobile app (and you should try it out!), your phone won't be able to access localhost directly. You'll need to create a publicly accessible URL using a tool like [ngrok](https://ngrok.com/) to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token. From 16c4aebd93bf6c5fc44ceafbc14c15ab14e0f368 Mon Sep 17 00:00:00 2001 From: Jeffrey Linwood Date: Sat, 28 Sep 2019 15:04:43 -0500 Subject: [PATCH 04/14] Update libraries for PHP --- composer.json | 4 ++-- composer.lock | 40 +++++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 54baad4..67591fb 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "twilio/sdk": "5.22.0", - "vlucas/phpdotenv": "dev-master" + "twilio/sdk": "5.36.0", + "vlucas/phpdotenv": "3.6.0" } } diff --git a/composer.lock b/composer.lock index e11eba9..61edd5d 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "0cc1742d0846f4fd1089fd678bf269ef", + "content-hash": "e7999d254cb49d495664f8fa6c321ad4", "packages": [ { "name": "phpoption/phpoption", @@ -116,16 +116,16 @@ }, { "name": "twilio/sdk", - "version": "5.22.0", + "version": "5.36.0", "source": { "type": "git", "url": "https://github.com/twilio/twilio-php.git", - "reference": "9984743a96015258a7fec3a382cd789001278710" + "reference": "ad4093a19762b76b1ec316ebdb6e0766539859ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twilio/twilio-php/zipball/9984743a96015258a7fec3a382cd789001278710", - "reference": "9984743a96015258a7fec3a382cd789001278710", + "url": "https://api.github.com/repos/twilio/twilio-php/zipball/ad4093a19762b76b1ec316ebdb6e0766539859ff", + "reference": "ad4093a19762b76b1ec316ebdb6e0766539859ff", "shasum": "" }, "require": { @@ -133,12 +133,16 @@ }, "require-dev": { "apigen/apigen": "^4.1", - "phpunit/phpunit": "4.5.*" + "guzzlehttp/guzzle": "^6.3", + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "guzzlehttp/guzzle": "An HTTP client to execute the API requests" }, "type": "library", "autoload": { "psr-4": { - "Twilio\\": "Twilio/" + "Twilio\\": "src/Twilio/" } }, "notification-url": "https://packagist.org/downloads/", @@ -158,20 +162,20 @@ "sms", "twilio" ], - "time": "2018-09-21T21:35:30+00:00" + "time": "2019-09-18T22:10:18+00:00" }, { "name": "vlucas/phpdotenv", - "version": "dev-master", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "9159290ad347bf56fa6d208bf35645c450f9e567" + "reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/9159290ad347bf56fa6d208bf35645c450f9e567", - "reference": "9159290ad347bf56fa6d208bf35645c450f9e567", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1bdf24f065975594f6a117f0f1f6cabf1333b156", + "reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156", "shasum": "" }, "require": { @@ -180,12 +184,12 @@ "symfony/polyfill-ctype": "^1.9" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0" + "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "3.6-dev" } }, "autoload": { @@ -215,15 +219,13 @@ "env", "environment" ], - "time": "2019-06-29T14:13:05+00:00" + "time": "2019-09-10T21:37:39+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "vlucas/phpdotenv": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": [], From 4a4e90ff1da404b4bd82036707f34217c75b3ec6 Mon Sep 17 00:00:00 2001 From: Jeffrey Linwood Date: Tue, 2 Jun 2020 16:44:24 -0500 Subject: [PATCH 05/14] Update Twilio Chat JS to 3.4 --- webroot/chat/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webroot/chat/index.html b/webroot/chat/index.html index 9acc7ba..0813c11 100755 --- a/webroot/chat/index.html +++ b/webroot/chat/index.html @@ -19,8 +19,7 @@ - - + From d186d8df5ba9e72bc9ed761f51ab21904d4403c2 Mon Sep 17 00:00:00 2001 From: Jeffrey Linwood Date: Wed, 3 Jun 2020 10:59:30 -0500 Subject: [PATCH 06/14] Update Twilio lib, phpdotenv, and code that uses dotenv --- composer.json | 4 +- composer.lock | 109 +++++++++++++++++++++++----------- webroot/config-check.php | 2 +- webroot/register.php | 2 +- webroot/send-notification.php | 2 +- webroot/token.php | 2 +- 6 files changed, 79 insertions(+), 42 deletions(-) diff --git a/composer.json b/composer.json index 67591fb..292d9ae 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "twilio/sdk": "5.36.0", - "vlucas/phpdotenv": "3.6.0" + "twilio/sdk": "6.6.0", + "vlucas/phpdotenv": "4.1.6" } } diff --git a/composer.lock b/composer.lock index 61edd5d..dad3288 100644 --- a/composer.lock +++ b/composer.lock @@ -1,50 +1,55 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e7999d254cb49d495664f8fa6c321ad4", + "content-hash": "afdb92afd1852ff90429e046736a1ac7", "packages": [ { "name": "phpoption/phpoption", - "version": "1.5.0", + "version": "1.7.3", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed" + "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed", - "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/4acfd6a4b33a509d8c88f50e5222f734b6aeebae", + "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": "^5.5.9 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "4.7.*" + "bamarni/composer-bin-plugin": "^1.3", + "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.7-dev" } }, "autoload": { - "psr-0": { - "PhpOption\\": "src/" + "psr-4": { + "PhpOption\\": "src/PhpOption/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "Apache2" + "Apache-2.0" ], "authors": [ { "name": "Johannes M. Schmitt", "email": "schmittjoh@gmail.com" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com" } ], "description": "Option Type for PHP", @@ -54,20 +59,20 @@ "php", "type" ], - "time": "2015-07-25T16:39:46+00:00" + "time": "2020-03-21T18:07:53+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.12.0", + "version": "v1.17.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4" + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", - "reference": "550ebaac289296ce228a706d0867afc34687e3f4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", "shasum": "" }, "require": { @@ -79,7 +84,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-master": "1.17-dev" } }, "autoload": { @@ -112,29 +117,43 @@ "polyfill", "portable" ], - "time": "2019-08-06T08:03:45+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-05-12T16:14:59+00:00" }, { "name": "twilio/sdk", - "version": "5.36.0", + "version": "6.6.0", "source": { "type": "git", "url": "https://github.com/twilio/twilio-php.git", - "reference": "ad4093a19762b76b1ec316ebdb6e0766539859ff" + "reference": "eba44af458c63227acc9a2449f21733a6f72ce86" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twilio/twilio-php/zipball/ad4093a19762b76b1ec316ebdb6e0766539859ff", - "reference": "ad4093a19762b76b1ec316ebdb6e0766539859ff", + "url": "https://api.github.com/repos/twilio/twilio-php/zipball/eba44af458c63227acc9a2449f21733a6f72ce86", + "reference": "eba44af458c63227acc9a2449f21733a6f72ce86", "shasum": "" }, "require": { - "php": ">=5.5.0" + "php": ">=7.1.0" }, "require-dev": { - "apigen/apigen": "^4.1", "guzzlehttp/guzzle": "^6.3", - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": ">=4.5", + "theseer/phpdox": "^0.12.0" }, "suggest": { "guzzlehttp/guzzle": "An HTTP client to execute the API requests" @@ -162,34 +181,41 @@ "sms", "twilio" ], - "time": "2019-09-18T22:10:18+00:00" + "time": "2020-05-27T19:28:33+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v3.6.0", + "version": "v4.1.6", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156" + "reference": "0b32505d67c1abbfa829283c86bfc0642a661bf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/1bdf24f065975594f6a117f0f1f6cabf1333b156", - "reference": "1bdf24f065975594f6a117f0f1f6cabf1333b156", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/0b32505d67c1abbfa829283c86bfc0642a661bf6", + "reference": "0b32505d67c1abbfa829283c86bfc0642a661bf6", "shasum": "" }, "require": { - "php": "^5.4 || ^7.0", - "phpoption/phpoption": "^1.5", + "php": "^5.5.9 || ^7.0 || ^8.0", + "phpoption/phpoption": "^1.7.2", "symfony/polyfill-ctype": "^1.9" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.3", + "ext-filter": "*", + "ext-pcre": "*", "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" }, + "suggest": { + "ext-filter": "Required to use the boolean validator.", + "ext-pcre": "Required to use most of the library." + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.6-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -219,7 +245,17 @@ "env", "environment" ], - "time": "2019-09-10T21:37:39+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/vlucas/phpdotenv", + "type": "tidelift" + } + ], + "time": "2020-05-23T09:43:32+00:00" } ], "packages-dev": [], @@ -229,5 +265,6 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/webroot/config-check.php b/webroot/config-check.php index 84051ec..bb26a19 100644 --- a/webroot/config-check.php +++ b/webroot/config-check.php @@ -2,7 +2,7 @@ include('../vendor/autoload.php'); // Load environment variables from .env, or environment if available -$dotenv = Dotenv\Dotenv::create(__DIR__); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); header('Content-type:application/json;charset=utf-8'); diff --git a/webroot/register.php b/webroot/register.php index d9cb917..b34707f 100644 --- a/webroot/register.php +++ b/webroot/register.php @@ -2,7 +2,7 @@ include('../vendor/autoload.php'); // Load environment variables from .env, or environment if available -$dotenv = Dotenv\Dotenv::create(__DIR__); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); // Authenticate with Twilio diff --git a/webroot/send-notification.php b/webroot/send-notification.php index 588e09b..2dfe8ce 100644 --- a/webroot/send-notification.php +++ b/webroot/send-notification.php @@ -2,7 +2,7 @@ include('../vendor/autoload.php'); // Load environment variables from .env, or environment if available -$dotenv = Dotenv\Dotenv::create(__DIR__); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); // Authenticate with Twilio diff --git a/webroot/token.php b/webroot/token.php index 0c635d9..2ca9c89 100644 --- a/webroot/token.php +++ b/webroot/token.php @@ -9,7 +9,7 @@ use Twilio\Jwt\Grants\ChatGrant; // Load environment variables from .env, or environment if available -$dotenv = Dotenv\Dotenv::create(__DIR__); +$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); // An identifier for your app - can be anything you'd like From 31e33e6fee3d2df0cf82b6516eff22517b6df8b3 Mon Sep 17 00:00:00 2001 From: Jeffrey Linwood Date: Fri, 12 Jun 2020 08:17:30 -0500 Subject: [PATCH 07/14] Refresh access token when it is expired or about to expire, add identity to token.php as param --- webroot/chat/index.js | 28 ++++++++++++++++++++++------ webroot/token.php | 7 +++++-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/webroot/chat/index.js b/webroot/chat/index.js index c4513e3..58950c7 100755 --- a/webroot/chat/index.js +++ b/webroot/chat/index.js @@ -40,12 +40,8 @@ $(function() { // Alert the user they have been assigned a random username print('Logging in...'); - // Get an access token for the current user, passing a username (identity) - // and a device ID - for browser-based apps, we'll always just use the - // value "browser" - $.getJSON('/token.php', { - device: 'browser' - }, function(data) { + // Get an access token for the current user + $.getJSON('/token.php', function(data) { // Initialize the Chat client @@ -54,6 +50,16 @@ $(function() { chatClient = client; chatClient.getSubscribedChannels().then(createOrJoinGeneralChannel); + // when the access token is about to expire, refresh it + chatClient.on('tokenAboutToExpire', function() { + refreshToken(username); + }); + + // if the access token already expired, refresh it + chatClient.on('tokenExpired', function() { + refreshToken(username); + }); + // Alert the user they have been assigned a random username username = data.identity; print('You have been assigned a random username of: ' @@ -66,6 +72,16 @@ $(function() { }); }); + function refreshToken(identity) { + console.log('Token about to expire'); + // Make a secure request to your backend to retrieve a refreshed access token. + // Use an authentication mechanism to prevent token exposure to 3rd parties. + $.getJSON('/token.php', {identity, identity}, function(data) { + console.log('updated token for chat client'); + chatClient.updateToken(data.token); + }); + } + function createOrJoinGeneralChannel() { // Get the general chat channel, which is where all the messages are // sent in this simple application diff --git a/webroot/token.php b/webroot/token.php index 2ca9c89..d7f4fd6 100644 --- a/webroot/token.php +++ b/webroot/token.php @@ -15,8 +15,11 @@ // An identifier for your app - can be anything you'd like $appName = 'TwilioStarterDemo'; -// choose a random username for the connecting user -$identity = randomUsername(); +$identity = $_GET['identity']; +if (empty($identity)) { + // choose a random username for the connecting user (if one is not supplied) + $identity = randomUsername(); +} // Create access token, which we will serialize and send to the client $token = new AccessToken( From 648f67bb1e1e33e824720c921a3472780cbb4270 Mon Sep 17 00:00:00 2001 From: Jeffrey Linwood Date: Fri, 3 Jul 2020 18:37:00 -0500 Subject: [PATCH 08/14] Update Twilio + Dotenv, change getenv to --- composer.json | 4 +- composer.lock | 295 ++++++++++++++++++++++++++++++---- webroot/config-check.php | 14 +- webroot/register.php | 4 +- webroot/send-notification.php | 4 +- webroot/token.php | 14 +- 6 files changed, 285 insertions(+), 50 deletions(-) diff --git a/composer.json b/composer.json index 292d9ae..58a12e1 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "twilio/sdk": "6.6.0", - "vlucas/phpdotenv": "4.1.6" + "twilio/sdk": "6.8.0", + "vlucas/phpdotenv": "5.0.0" } } diff --git a/composer.lock b/composer.lock index dad3288..abe241c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,82 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "afdb92afd1852ff90429e046736a1ac7", + "content-hash": "c95c9732a79bb13a44b4d544177a9f6a", "packages": [ + { + "name": "graham-campbell/result-type", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/GrahamCampbell/Result-Type.git", + "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GrahamCampbell/Result-Type/zipball/7e279d2cd5d7fbb156ce46daada972355cea27bb", + "reference": "7e279d2cd5d7fbb156ce46daada972355cea27bb", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0", + "phpoption/phpoption": "^1.7.3" + }, + "require-dev": { + "phpunit/phpunit": "^6.5|^7.5|^8.5|^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GrahamCampbell\\ResultType\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "graham@alt-three.com" + } + ], + "description": "An Implementation Of The Result Type", + "keywords": [ + "Graham Campbell", + "GrahamCampbell", + "Result Type", + "Result-Type", + "result" + ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/graham-campbell/result-type", + "type": "tidelift" + } + ], + "time": "2020-04-13T13:17:36+00:00" + }, { "name": "phpoption/phpoption", - "version": "1.7.3", + "version": "1.7.4", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae" + "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/4acfd6a4b33a509d8c88f50e5222f734b6aeebae", - "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", "shasum": "" }, "require": { @@ -59,20 +121,30 @@ "php", "type" ], - "time": "2020-03-21T18:07:53+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption", + "type": "tidelift" + } + ], + "time": "2020-06-07T10:40:07+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.0", + "version": "v1.17.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", "shasum": "" }, "require": { @@ -85,6 +157,10 @@ "extra": { "branch-alias": { "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -131,20 +207,177 @@ "type": "tidelift" } ], - "time": "2020-05-12T16:14:59+00:00" + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", + "reference": "7110338d81ce1cbc3e273136e4574663627037a7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com/", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-06T08:46:27+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "shasum": "" + }, + "require": { + "php": ">=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com/", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-06-06T08:46:27+00:00" }, { "name": "twilio/sdk", - "version": "6.6.0", + "version": "6.8.0", "source": { "type": "git", "url": "https://github.com/twilio/twilio-php.git", - "reference": "eba44af458c63227acc9a2449f21733a6f72ce86" + "reference": "1c3c2ac948581d0c1e410374ff6c4155c85f1e10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twilio/twilio-php/zipball/eba44af458c63227acc9a2449f21733a6f72ce86", - "reference": "eba44af458c63227acc9a2449f21733a6f72ce86", + "url": "https://api.github.com/repos/twilio/twilio-php/zipball/1c3c2ac948581d0c1e410374ff6c4155c85f1e10", + "reference": "1c3c2ac948581d0c1e410374ff6c4155c85f1e10", "shasum": "" }, "require": { @@ -181,41 +414,43 @@ "sms", "twilio" ], - "time": "2020-05-27T19:28:33+00:00" + "time": "2020-06-24T21:45:53+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v4.1.6", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "0b32505d67c1abbfa829283c86bfc0642a661bf6" + "reference": "fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/0b32505d67c1abbfa829283c86bfc0642a661bf6", - "reference": "0b32505d67c1abbfa829283c86bfc0642a661bf6", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e", + "reference": "fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0 || ^8.0", - "phpoption/phpoption": "^1.7.2", - "symfony/polyfill-ctype": "^1.9" + "ext-pcre": "*", + "graham-campbell/result-type": "^1.0.1", + "php": "^7.1.3 || ^8.0", + "phpoption/phpoption": "^1.7.4", + "symfony/polyfill-ctype": "^1.17", + "symfony/polyfill-mbstring": "^1.17", + "symfony/polyfill-php80": "^1.17" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.3", + "bamarni/composer-bin-plugin": "^1.4.1", "ext-filter": "*", - "ext-pcre": "*", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^7.5.20 || ^8.5.2 || ^9.0" }, "suggest": { - "ext-filter": "Required to use the boolean validator.", - "ext-pcre": "Required to use most of the library." + "ext-filter": "Required to use the boolean validator." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -255,7 +490,7 @@ "type": "tidelift" } ], - "time": "2020-05-23T09:43:32+00:00" + "time": "2020-06-07T19:04:14+00:00" } ], "packages-dev": [], diff --git a/webroot/config-check.php b/webroot/config-check.php index bb26a19..47fcbb0 100644 --- a/webroot/config-check.php +++ b/webroot/config-check.php @@ -7,21 +7,21 @@ header('Content-type:application/json;charset=utf-8'); -$syncServiceSID = getenv('TWILIO_SYNC_SERVICE_SID'); +$syncServiceSID = $_ENV['TWILIO_SYNC_SERVICE_SID']; if (empty($syncServiceSID)) { $syncServiceSID = 'default'; } // Ensure that the Sync Default Service is provisioned if ($syncServiceSID === 'default') { - $client = new Twilio\Rest\Client(getenv('TWILIO_API_KEY'), getenv('TWILIO_API_SECRET'), getenv('TWILIO_ACCOUNT_SID')); + $client = new Twilio\Rest\Client($_ENV['TWILIO_API_KEY'], $_ENV['TWILIO_API_SECRET'], $_ENV['TWILIO_ACCOUNT_SID']); $client->sync->services($syncServiceSID)->fetch(); } echo json_encode(array( - 'TWILIO_ACCOUNT_SID' => getenv('TWILIO_ACCOUNT_SID'), - 'TWILIO_NOTIFICATION_SERVICE_SID' => getenv('TWILIO_NOTIFICATION_SERVICE_SID'), - 'TWILIO_CHAT_SERVICE_SID' => getenv('TWILIO_CHAT_SERVICE_SID'), + 'TWILIO_ACCOUNT_SID' => $_ENV['TWILIO_ACCOUNT_SID'], + 'TWILIO_NOTIFICATION_SERVICE_SID' => $_ENV['TWILIO_NOTIFICATION_SERVICE_SID'], + 'TWILIO_CHAT_SERVICE_SID' => $_ENV['TWILIO_CHAT_SERVICE_SID'], 'TWILIO_SYNC_SERVICE_SID' => $syncServiceSID, - 'TWILIO_API_KEY' => getenv('TWILIO_API_KEY'), - 'TWILIO_API_SECRET' => !empty(getenv('TWILIO_API_SECRET')), + 'TWILIO_API_KEY' => $_ENV['TWILIO_API_KEY'], + 'TWILIO_API_SECRET' => !empty($_ENV['TWILIO_API_SECRET']), )); diff --git a/webroot/register.php b/webroot/register.php index b34707f..4de710b 100644 --- a/webroot/register.php +++ b/webroot/register.php @@ -6,10 +6,10 @@ $dotenv->load(); // Authenticate with Twilio -$client = new Twilio\Rest\Client(getenv('TWILIO_API_KEY'), getenv('TWILIO_API_SECRET'), getenv('TWILIO_ACCOUNT_SID')); +$client = new Twilio\Rest\Client($_ENV['TWILIO_API_KEY'], $_ENV['TWILIO_API_SECRET'], $_ENV['TWILIO_ACCOUNT_SID']); // Get a reference to the user notification service instance -$service = $client->notify->v1->services(getenv('TWILIO_NOTIFICATION_SERVICE_SID')); +$service = $client->notify->v1->services($_ENV['TWILIO_NOTIFICATION_SERVICE_SID']); $json = json_decode(file_get_contents('php://input'), true); diff --git a/webroot/send-notification.php b/webroot/send-notification.php index 2dfe8ce..35abc59 100644 --- a/webroot/send-notification.php +++ b/webroot/send-notification.php @@ -6,10 +6,10 @@ $dotenv->load(); // Authenticate with Twilio -$client = new Twilio\Rest\Client(getenv('TWILIO_API_KEY'), getenv('TWILIO_API_SECRET'), getenv('TWILIO_ACCOUNT_SID')); +$client = new Twilio\Rest\Client($_ENV['TWILIO_API_KEY'], $_ENV['TWILIO_API_SECRET'], $_ENV['TWILIO_ACCOUNT_SID']); // Send a notification -$service = $client->notify->v1->services(getenv('TWILIO_NOTIFICATION_SERVICE_SID')); +$service = $client->notify->v1->services($_ENV['TWILIO_NOTIFICATION_SERVICE_SID']); $json = json_decode(file_get_contents('php://input'), true); diff --git a/webroot/token.php b/webroot/token.php index d7f4fd6..7e13ce6 100644 --- a/webroot/token.php +++ b/webroot/token.php @@ -23,9 +23,9 @@ // Create access token, which we will serialize and send to the client $token = new AccessToken( - getenv('TWILIO_ACCOUNT_SID'), - getenv('TWILIO_API_KEY'), - getenv('TWILIO_API_SECRET'), + $_ENV['TWILIO_ACCOUNT_SID'], + $_ENV['TWILIO_API_KEY'], + $_ENV['TWILIO_API_SECRET'], 3600, $identity ); @@ -36,17 +36,17 @@ // Grant access to Sync $syncGrant = new SyncGrant(); -if (empty(getenv('TWILIO_SYNC_SERVICE_SID'))) { +if (empty($_ENV['TWILIO_SYNC_SERVICE_SID'])) { $syncGrant->setServiceSid('default'); } else { - $syncGrant->setServiceSid(getenv('TWILIO_SYNC_SERVICE_SID')); + $syncGrant->setServiceSid($_ENV['TWILIO_SYNC_SERVICE_SID']); } $token->addGrant($syncGrant); // Grant access to Chat -if (!empty(getenv('TWILIO_CHAT_SERVICE_SID'))) { +if (!empty($_ENV['TWILIO_CHAT_SERVICE_SID'])) { $chatGrant = new ChatGrant(); - $chatGrant->setServiceSid(getenv('TWILIO_CHAT_SERVICE_SID')); + $chatGrant->setServiceSid($_ENV['TWILIO_CHAT_SERVICE_SID']); $token->addGrant($chatGrant); } From fb3ebb5e2d6944765870a2213c16427b9d9d103a Mon Sep 17 00:00:00 2001 From: Jeff Linwood Date: Wed, 22 Jul 2020 15:02:33 -0500 Subject: [PATCH 09/14] Update Twilio Chat JS --- webroot/chat/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webroot/chat/index.html b/webroot/chat/index.html index 0813c11..e03ec33 100755 --- a/webroot/chat/index.html +++ b/webroot/chat/index.html @@ -19,7 +19,7 @@ - + From 9418fecb1bfba701f0df374805350083efcae003 Mon Sep 17 00:00:00 2001 From: Jeff Linwood Date: Fri, 28 Aug 2020 18:36:41 -0500 Subject: [PATCH 10/14] Update to remove PHP error message when checking unset identity param --- webroot/token.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webroot/token.php b/webroot/token.php index 7e13ce6..bd57825 100644 --- a/webroot/token.php +++ b/webroot/token.php @@ -12,10 +12,12 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); -// An identifier for your app - can be anything you'd like -$appName = 'TwilioStarterDemo'; +$identity = ''; + +if (isset($_GET['identity'])) { + $identity = $_GET['identity']; +} -$identity = $_GET['identity']; if (empty($identity)) { // choose a random username for the connecting user (if one is not supplied) $identity = randomUsername(); From 98518c7bce5254d85240a9e5455d4c821cd49847 Mon Sep 17 00:00:00 2001 From: Jeff Linwood Date: Fri, 27 Nov 2020 19:28:29 -0600 Subject: [PATCH 11/14] Update dependencies --- composer.json | 4 +- composer.lock | 109 +++++++++++++++++++++++++++++++------------------- 2 files changed, 69 insertions(+), 44 deletions(-) diff --git a/composer.json b/composer.json index 58a12e1..5eb43fb 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "twilio/sdk": "6.8.0", - "vlucas/phpdotenv": "5.0.0" + "twilio/sdk": "6.13.0", + "vlucas/phpdotenv": "5.2.0" } } diff --git a/composer.lock b/composer.lock index abe241c..3950598 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c95c9732a79bb13a44b4d544177a9f6a", + "content-hash": "966f401005b2b3203497276ae7a8e93c", "packages": [ { "name": "graham-campbell/result-type", @@ -56,6 +56,10 @@ "Result-Type", "result" ], + "support": { + "issues": "https://github.com/GrahamCampbell/Result-Type/issues", + "source": "https://github.com/GrahamCampbell/Result-Type/tree/v1.0.1" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -70,24 +74,24 @@ }, { "name": "phpoption/phpoption", - "version": "1.7.4", + "version": "1.7.5", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3" + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", - "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525", + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525", "shasum": "" }, "require": { "php": "^5.5.9 || ^7.0 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.3", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { @@ -121,6 +125,10 @@ "php", "type" ], + "support": { + "issues": "https://github.com/schmittjoh/php-option/issues", + "source": "https://github.com/schmittjoh/php-option/tree/1.7.5" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -131,24 +139,24 @@ "type": "tidelift" } ], - "time": "2020-06-07T10:40:07+00:00" + "time": "2020-07-20T17:29:33+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.1", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" + "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", + "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-ctype": "For best performance" @@ -156,7 +164,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.20-dev" }, "thanks": { "name": "symfony/polyfill", @@ -193,6 +201,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -207,24 +218,24 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-10-23T14:02:19+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.17.1", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7" + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-mbstring": "For best performance" @@ -232,7 +243,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.20-dev" }, "thanks": { "name": "symfony/polyfill", @@ -270,6 +281,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -284,29 +298,29 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-10-23T14:02:19+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.17.1", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de", "shasum": "" }, "require": { - "php": ">=7.0.8" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-main": "1.20-dev" }, "thanks": { "name": "symfony/polyfill", @@ -350,6 +364,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -364,27 +381,27 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-10-23T14:02:19+00:00" }, { "name": "twilio/sdk", - "version": "6.8.0", + "version": "6.13.0", "source": { "type": "git", "url": "https://github.com/twilio/twilio-php.git", - "reference": "1c3c2ac948581d0c1e410374ff6c4155c85f1e10" + "reference": "df14c92ae0c6604ffe88c9880ad78851c42f7b21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twilio/twilio-php/zipball/1c3c2ac948581d0c1e410374ff6c4155c85f1e10", - "reference": "1c3c2ac948581d0c1e410374ff6c4155c85f1e10", + "url": "https://api.github.com/repos/twilio/twilio-php/zipball/df14c92ae0c6604ffe88c9880ad78851c42f7b21", + "reference": "df14c92ae0c6604ffe88c9880ad78851c42f7b21", "shasum": "" }, "require": { "php": ">=7.1.0" }, "require-dev": { - "guzzlehttp/guzzle": "^6.3", + "guzzlehttp/guzzle": "^6.3 || ^7.0", "phpunit/phpunit": ">=4.5", "theseer/phpdox": "^0.12.0" }, @@ -414,20 +431,24 @@ "sms", "twilio" ], - "time": "2020-06-24T21:45:53+00:00" + "support": { + "issues": "https://github.com/twilio/twilio-php/issues", + "source": "https://github.com/twilio/twilio-php/tree/6.13.0" + }, + "time": "2020-11-19T00:40:06+00:00" }, { "name": "vlucas/phpdotenv", - "version": "v5.0.0", + "version": "v5.2.0", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e" + "reference": "fba64139db67123c7a57072e5f8d3db10d160b66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e", - "reference": "fbb6a5f65512f21d0db9e21bd49e67f70a9bbd5e", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/fba64139db67123c7a57072e5f8d3db10d160b66", + "reference": "fba64139db67123c7a57072e5f8d3db10d160b66", "shasum": "" }, "require": { @@ -450,7 +471,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.2-dev" } }, "autoload": { @@ -480,6 +501,10 @@ "env", "environment" ], + "support": { + "issues": "https://github.com/vlucas/phpdotenv/issues", + "source": "https://github.com/vlucas/phpdotenv/tree/v5.2.0" + }, "funding": [ { "url": "https://github.com/GrahamCampbell", @@ -490,7 +515,7 @@ "type": "tidelift" } ], - "time": "2020-06-07T19:04:14+00:00" + "time": "2020-09-14T15:57:31+00:00" } ], "packages-dev": [], @@ -501,5 +526,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } From ab783bf3a766777c3320f1b1adfddf669431967e Mon Sep 17 00:00:00 2001 From: Kevin Whinnery Date: Tue, 20 Apr 2021 17:46:46 -0500 Subject: [PATCH 12/14] use only positive adjectives --- webroot/randos.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webroot/randos.php b/webroot/randos.php index 21b3a57..306d49a 100644 --- a/webroot/randos.php +++ b/webroot/randos.php @@ -3,10 +3,10 @@ // Generate a random username for the connecting client function randomUsername() { $ADJECTIVES = array( - 'Abrasive', 'Brash', 'Callous', 'Daft', 'Eccentric', 'Fiesty', 'Golden', - 'Holy', 'Ignominious', 'Joltin', 'Killer', 'Luscious', 'Mushy', 'Nasty', - 'OldSchool', 'Pompous', 'Quiet', 'Rowdy', 'Sneaky', 'Tawdry', - 'Unique', 'Vivacious', 'Wicked', 'Xenophobic', 'Yawning', 'Zesty', + 'Awesome', 'Bold', 'Creative', 'Dapper', 'Eccentric', 'Fiesty', 'Golden', + 'Holy', 'Ignominious', 'Jolly', 'Kindly', 'Lucky', 'Mushy', 'Natural', + 'Oaken', 'Precise', 'Quiet', 'Rowdy', 'Sunny', 'Tall', + 'Unique', 'Vivacious', 'Wonderful', 'Xtra', 'Yawning', 'Zesty', ); $FIRST_NAMES = array( @@ -30,4 +30,4 @@ function randomUsername() { $ln = $LAST_NAMES[array_rand($LAST_NAMES)]; return $adj . $fn . $ln; -} \ No newline at end of file +} From d42423bda6419d2ecca5f9563b2864baf5cdef22 Mon Sep 17 00:00:00 2001 From: Kevin Whinnery Date: Tue, 20 Apr 2021 17:51:54 -0500 Subject: [PATCH 13/14] Update randos.php --- webroot/randos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webroot/randos.php b/webroot/randos.php index 306d49a..64747d6 100644 --- a/webroot/randos.php +++ b/webroot/randos.php @@ -6,7 +6,7 @@ function randomUsername() { 'Awesome', 'Bold', 'Creative', 'Dapper', 'Eccentric', 'Fiesty', 'Golden', 'Holy', 'Ignominious', 'Jolly', 'Kindly', 'Lucky', 'Mushy', 'Natural', 'Oaken', 'Precise', 'Quiet', 'Rowdy', 'Sunny', 'Tall', - 'Unique', 'Vivacious', 'Wonderful', 'Xtra', 'Yawning', 'Zesty', + 'Unique', 'Vivid', 'Wonderful', 'Xtra', 'Yawning', 'Zesty', ); $FIRST_NAMES = array( From d637bc4df3f1b4675312ddb7c86b8296c00915dc Mon Sep 17 00:00:00 2001 From: Stefani Castellanos Date: Tue, 28 Sep 2021 07:26:59 -0500 Subject: [PATCH 14/14] Obscure sensible values on .env (#50) --- .gitignore | 1 - README.md | 4 ++++ webroot/.env.example | 3 +++ webroot/config-check.js | 2 +- webroot/register.php | 3 +++ webroot/send-notification.php | 4 +++- webroot/token.php | 3 +++ 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fcd8c07..8941c05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .env -config.php composer.phar /vendor/ diff --git a/README.md b/README.md index ff3d67d..8b51218 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ cp .env.example .env Open `.env` in your favorite text editor and configure the following values. +On production, to avoid showing errors, you should set the variable `DISPLAY_ERRORS` to +`0`. For development, it can be set to `1` on development. For more information, read +[this](https://phpdelusions.net/articles/error_reporting) + ### Configure account information Every sample in the demo requires some basic credentials from your Twilio account. Configure these first. diff --git a/webroot/.env.example b/webroot/.env.example index 61512b1..a4ee486 100644 --- a/webroot/.env.example +++ b/webroot/.env.example @@ -1,3 +1,6 @@ +# Set it to 0 when running on production. See the README for further explanation +DISPLAY_ERRORS=0 + # Required for all uses TWILIO_ACCOUNT_SID=ACXXXXXXXXXXXXXXXXX TWILIO_API_KEY=SKXXXXXXXXXXXXXXXXX diff --git a/webroot/config-check.js b/webroot/config-check.js index 90e1cc5..c92ecfc 100644 --- a/webroot/config-check.js +++ b/webroot/config-check.js @@ -23,7 +23,7 @@ $(function() { }; var configureField = function(fields, response) { - var htmlContent = 'Not configured in config.php'; + var htmlContent = 'Not configured in .env'; var cssClass = 'unset'; return function(fieldId) { var configKey = strToConfig(fieldId); diff --git a/webroot/register.php b/webroot/register.php index 4de710b..e0cbbce 100644 --- a/webroot/register.php +++ b/webroot/register.php @@ -5,6 +5,9 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); +$DISPLAY_ERRORS = $_ENV['DISPLAY_ERRORS']; +ini_set('display_errors', $DISPLAY_ERRORS); + // Authenticate with Twilio $client = new Twilio\Rest\Client($_ENV['TWILIO_API_KEY'], $_ENV['TWILIO_API_SECRET'], $_ENV['TWILIO_ACCOUNT_SID']); diff --git a/webroot/send-notification.php b/webroot/send-notification.php index 35abc59..674fecb 100644 --- a/webroot/send-notification.php +++ b/webroot/send-notification.php @@ -5,6 +5,9 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); +$DISPLAY_ERRORS = $_ENV['DISPLAY_ERRORS']; +ini_set('display_errors', $DISPLAY_ERRORS); + // Authenticate with Twilio $client = new Twilio\Rest\Client($_ENV['TWILIO_API_KEY'], $_ENV['TWILIO_API_SECRET'], $_ENV['TWILIO_ACCOUNT_SID']); @@ -13,7 +16,6 @@ $json = json_decode(file_get_contents('php://input'), true); - try { $notification = $service->notifications->create( [ diff --git a/webroot/token.php b/webroot/token.php index bd57825..f58120b 100644 --- a/webroot/token.php +++ b/webroot/token.php @@ -12,6 +12,9 @@ $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); +$DISPLAY_ERRORS = $_ENV['DISPLAY_ERRORS']; +ini_set('display_errors', $DISPLAY_ERRORS); + $identity = ''; if (isset($_GET['identity'])) {