From 663e1d61a1904a63d4b698c07d2482dd1d22db20 Mon Sep 17 00:00:00 2001 From: Alex Ciarlillo Date: Mon, 16 Apr 2018 11:11:21 -0400 Subject: [PATCH] remove league/uri dependency --- composer.json | 3 +- composer.lock | 476 +----------------------------- src/CloudFrontUrlSigner.php | 5 +- tests/SignatureGenerationTest.php | 6 +- 4 files changed, 11 insertions(+), 479 deletions(-) diff --git a/composer.json b/composer.json index 32be27d..043e4fc 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,7 @@ "require": { "php" : "^7.1", "illuminate/support": "~5.5.0|~5.6.0", - "aws/aws-sdk-php": "^3.52", - "league/uri": "^5.2" + "aws/aws-sdk-php": "^3.52" }, "require-dev": { "orchestra/testbench": "~3.4.4|~3.5.0|~3.6.0", diff --git a/composer.lock b/composer.lock index 832d87d..39348af 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "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": "f6342eaa1fb16d1da092de6cabc65759", + "content-hash": "0f45b28dd5d998a57e3353fbca608f2f", "packages": [ { "name": "aws/aws-sdk-php", @@ -708,470 +708,6 @@ ], "time": "2018-01-27T16:03:56+00:00" }, - { - "name": "league/uri", - "version": "5.2.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri.git", - "reference": "872194ac1ca5e51fbb9e0e5ba4d27f91aa783e82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri/zipball/872194ac1ca5e51fbb9e0e5ba4d27f91aa783e82", - "reference": "872194ac1ca5e51fbb9e0e5ba4d27f91aa783e82", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "ext-intl": "*", - "ext-mbstring": "*", - "league/uri-components": "^1.5.0", - "league/uri-hostname-parser": "^1.0.4", - "league/uri-interfaces": "^1.0", - "league/uri-manipulations": "^1.3", - "league/uri-parser": "^1.3.0", - "league/uri-schemes": "^1.1.1", - "php": ">=7.0.13", - "psr/http-message": "^1.0" - }, - "type": "metapackage", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI manipulation library", - "homepage": "http://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file-uri", - "ftp", - "hostname", - "http", - "https", - "middleware", - "parse_str", - "parse_url", - "psr-7", - "query-string", - "querystring", - "rfc3986", - "rfc3987", - "uri", - "url", - "ws" - ], - "time": "2017-12-01T13:36:42+00:00" - }, - { - "name": "league/uri-components", - "version": "1.7.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-components.git", - "reference": "0a82a42327555f47929f56c7a2c89981ebe27e74" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-components/zipball/0a82a42327555f47929f56c7a2c89981ebe27e74", - "reference": "0a82a42327555f47929f56c7a2c89981ebe27e74", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "ext-fileinfo": "*", - "ext-intl": "*", - "ext-mbstring": "*", - "league/uri-hostname-parser": "^1.1.0", - "php": ">=7.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.3", - "phpstan/phpstan": "^0.9.0", - "phpunit/phpunit": "^6.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI components manipulation library", - "homepage": "http://uri.thephpleague.com", - "keywords": [ - "authority", - "components", - "fragment", - "host", - "path", - "port", - "query", - "rfc3986", - "scheme", - "uri", - "url", - "userinfo" - ], - "time": "2018-01-31T12:09:52+00:00" - }, - { - "name": "league/uri-hostname-parser", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-hostname-parser.git", - "reference": "33cdfd185e775efb0b87b7fb6485604a6da43128" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-hostname-parser/zipball/33cdfd185e775efb0b87b7fb6485604a6da43128", - "reference": "33cdfd185e775efb0b87b7fb6485604a6da43128", - "shasum": "" - }, - "require": { - "ext-intl": "*", - "php": ">=7.0", - "psr/simple-cache": "^1" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.7", - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^6.3" - }, - "suggest": { - "ext-curl": "To use the bundle cURL HTTP client", - "psr/simple-cache-implementation": "To enable using other cache providers" - }, - "bin": [ - "bin/update-psl-icann-section" - ], - "type": "library", - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jeremy Kendall", - "homepage": "http://about.me/jeremykendall", - "role": "Developer" - }, - { - "name": "Ignace Nyamagana Butera", - "homepage": "http://nyamsprod.com", - "role": "Developer" - }, - { - "name": "Contributors", - "homepage": "https://github.com/phpleague/uri-hostname-parser/graphs/contributors" - } - ], - "description": "ICANN base hostname parsing implemented in PHP.", - "homepage": "https://github.com/thephphleague/uri-hostname-parser", - "keywords": [ - "Public Suffix List", - "domain parsing", - "icann" - ], - "time": "2018-01-30T09:22:45+00:00" - }, - { - "name": "league/uri-interfaces", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "dcc0be58e8b35a726274249e5eee053be1a56b66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/dcc0be58e8b35a726274249e5eee053be1a56b66", - "reference": "dcc0be58e8b35a726274249e5eee053be1a56b66", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^1.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\Interfaces\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "Common interface for URI representation", - "homepage": "http://github.com/thephpleague/uri-interfaces", - "keywords": [ - "rfc3986", - "rfc3987", - "uri", - "url" - ], - "time": "2017-01-04T08:02:42+00:00" - }, - { - "name": "league/uri-manipulations", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-manipulations.git", - "reference": "7b1344490a293e2bd2a313afc6a95927cec4c2b3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-manipulations/zipball/7b1344490a293e2bd2a313afc6a95927cec4c2b3", - "reference": "7b1344490a293e2bd2a313afc6a95927cec4c2b3", - "shasum": "" - }, - "require": { - "league/uri-components": "^1.7.0", - "league/uri-interfaces": "^1.0", - "php": ">=7.0", - "psr/http-message": "^1.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "guzzlehttp/psr7": "^1.2", - "league/uri-schemes": "^1.0", - "phpunit/phpunit": "^6.0", - "zendframework/zend-diactoros": "1.4.0" - }, - "suggest": { - "league/uri-schemes": "Allow manipulating URI objects" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI manipulation library", - "homepage": "http://url.thephpleague.com", - "keywords": [ - "formatter", - "manipulation", - "manipulations", - "middlewares", - "modifiers", - "psr-7", - "references", - "rfc3986", - "rfc3987", - "uri", - "url" - ], - "time": "2018-02-06T11:37:57+00:00" - }, - { - "name": "league/uri-parser", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-parser.git", - "reference": "f3c99b77f0cba4446dad2eca8c57227fcda0f39b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-parser/zipball/f3c99b77f0cba4446dad2eca8c57227fcda0f39b", - "reference": "f3c99b77f0cba4446dad2eca8c57227fcda0f39b", - "shasum": "" - }, - "require": { - "ext-intl": "*", - "php": ">=7.0.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "league/uri-schemes": "Allow validating and normalizing URI parsing results" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "userland URI parser RFC 3986 compliant", - "homepage": "https://github.com/thephpleague/uri-parser", - "keywords": [ - "parse_url", - "parser", - "rfc3986", - "uri", - "url" - ], - "time": "2017-12-01T11:53:01+00:00" - }, - { - "name": "league/uri-schemes", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/uri-schemes.git", - "reference": "fd2448689186bfff27a112aa21d82931f4b366c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-schemes/zipball/fd2448689186bfff27a112aa21d82931f4b366c5", - "reference": "fd2448689186bfff27a112aa21d82931f4b366c5", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "ext-intl": "*", - "ext-mbstring": "*", - "league/uri-interfaces": "^1.0", - "league/uri-parser": "^1.3.0", - "php": ">=7.0.13", - "psr/http-message": "^1.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.0", - "phpunit/phpunit": "^6.0" - }, - "suggest": { - "league/uri-manipulations": "Needed to easily manipulate URI objects" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Uri\\": "src" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ignace Nyamagana Butera", - "email": "nyamsprod@gmail.com", - "homepage": "https://nyamsprod.com" - } - ], - "description": "URI manipulation library", - "homepage": "http://uri.thephpleague.com", - "keywords": [ - "data-uri", - "file", - "ftp", - "http", - "https", - "parse_url", - "psr-7", - "rfc3986", - "uri", - "url", - "ws", - "wss" - ], - "time": "2017-12-01T12:05:37+00:00" - }, { "name": "monolog/monolog", "version": "1.23.0", @@ -1598,16 +1134,16 @@ }, { "name": "psr/simple-cache", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/php-fig/simple-cache.git", - "reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24" + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/753fa598e8f3b9966c886fe13f370baa45ef0e24", - "reference": "753fa598e8f3b9966c886fe13f370baa45ef0e24", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", "shasum": "" }, "require": { @@ -1642,7 +1178,7 @@ "psr-16", "simple-cache" ], - "time": "2017-01-02T13:31:39+00:00" + "time": "2017-10-23T01:57:42+00:00" }, { "name": "ramsey/uuid", diff --git a/src/CloudFrontUrlSigner.php b/src/CloudFrontUrlSigner.php index b64db4c..691938d 100644 --- a/src/CloudFrontUrlSigner.php +++ b/src/CloudFrontUrlSigner.php @@ -4,7 +4,6 @@ use DateTime; use Dreamonkey\CloudFrontUrlSigner\Exceptions\InvalidExpiration; -use League\Uri\Http; class CloudFrontUrlSigner implements UrlSigner { @@ -34,12 +33,10 @@ public function __construct(\Aws\CloudFront\UrlSigner $urlSigner) */ public function sign(string $url, $expiration = null): string { - $resourceKey = Http::createFromString($url); - $expiration = $this->getExpirationTimestamp($expiration ?? config('cloudfront-url-signer.default_expiration_time_in_days')); - return $this->urlSigner->getSignedUrl($resourceKey, $expiration); + return $this->urlSigner->getSignedUrl($url, $expiration); } /** diff --git a/tests/SignatureGenerationTest.php b/tests/SignatureGenerationTest.php index 5d3ccae..2b31469 100644 --- a/tests/SignatureGenerationTest.php +++ b/tests/SignatureGenerationTest.php @@ -4,8 +4,6 @@ use DateTime; use DateTimeZone; -use League\Uri\Components\Query; -use League\Uri\Http; class SignatureGenerationTest extends TestCase { @@ -95,6 +93,8 @@ public function it_does_not_allow_expiration_in_the_past_when_datetime_is_given( */ private function getSignedUrlExpirationTimestamp(string $signedUrl): int { - return (int)(new Query(Http::createFromString($signedUrl)->getQuery()))->getParam('Expires'); + $parts = parse_url($signedUrl); + parse_str($parts['query'], $queryParams); + return (int)$queryParams['Expires']; } }