diff --git a/composer.json b/composer.json index e9a5b37..f7d8ab0 100644 --- a/composer.json +++ b/composer.json @@ -1,54 +1,60 @@ { - "name": "pterotype/activitypub-php", - "description": "An ActivityPub library", - "license": "MIT", - "authors": [ - { - "name": "Jeremy Dormitzer", - "email": "jeremy@dormitzer.net", - "homepage": "https://jeremydormitzer.com", - "role": "Developer" - } - ], - "scripts": { - "test": "phpunit -c ./test/config.xml test", - "test-debug": "XDEBUG_CONFIG='idekey=ap_session' php ./vendor/bin/phpunit test", - "docs": "phpdoc -d ./src -t ./docs" - }, - "repositories": [ - { - "type": "vcs", - "url": "https://git.friendi.ca/friendica/php-json-ld" - } - ], - "require": { - "doctrine/orm": "^2.6", - "friendica/json-ld": "^1.1", - "guzzlehttp/guzzle": "^6.3", - "phpseclib/phpseclib": "^2.0", - "psr/http-message": "^1.0", - "symfony/dependency-injection": "^4.2", - "symfony/http-kernel": "^4.2", - "symfony/psr-http-message-bridge": "^1.1", - "zendframework/zend-diactoros": "^1.8", - "ext-json": "*" - }, - "require-dev": { - "phpunit/dbunit": "^2.0", - "phpunit/phpunit": "^4.0", - "ext-pdo": "*" - }, - "autoload": { - "psr-4": { - "ActivityPub\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "ActivityPub\\Test\\": "test/" - } - }, - "config": { - "sort-packages": true + "name": "pterotype/activitypub-php", + "description": "An ActivityPub library", + "license": "MIT", + "authors": [ + { + "name": "Jeremy Dormitzer", + "email": "jeremy@dormitzer.net", + "homepage": "https://jeremydormitzer.com", + "role": "Developer" } + ], + "scripts": { + "test": "phpunit -c ./test/config.xml test", + "test-debug": "XDEBUG_CONFIG='idekey=ap_session' php ./vendor/bin/phpunit test", + "docs": "phpdoc -d ./src -t ./docs" + }, + "repositories": [ + { + "type": "vcs", + "url": "https://git.friendi.ca/friendica/php-json-ld" + } + ], + "require": { + "ext-json": "*", + "doctrine/annotations": "1.2.7", + "doctrine/cache": "1.6.2", + "doctrine/common": "2.6.2", + "doctrine/instantiator": "1.0.5", + "doctrine/orm": "2.5.14", + "friendica/json-ld": "^1.1", + "guzzlehttp/guzzle": "^6.3", + "phpseclib/phpseclib": "^2.0", + "psr/http-message": "^1.0", + "symfony/dependency-injection": "^3.4", + "symfony/event-dispatcher": "^3.4", + "symfony/http-foundation": "^3.4", + "symfony/http-kernel": "^3.4", + "symfony/psr-http-message-bridge": "^1.1", + "zendframework/zend-diactoros": "1.4.1" + }, + "require-dev": { + "phpunit/dbunit": "^2.0", + "phpunit/phpunit": "^4.0", + "ext-pdo": "*" + }, + "autoload": { + "psr-4": { + "ActivityPub\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "ActivityPub\\Test\\": "test/" + } + }, + "config": { + "sort-packages": true + } } diff --git a/composer.lock b/composer.lock index 28795cb..061a962 100644 --- a/composer.lock +++ b/composer.lock @@ -4,39 +4,39 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2d1f5780856feb51761f2c0a5a39cf07", + "content-hash": "b624fbe63ec43847c5e8cd411676d072", "packages": [ { "name": "doctrine/annotations", - "version": "v1.6.0", + "version": "v1.2.7", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", - "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": "^7.1" + "php": ">=5.3.2" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "4.*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.3.x-dev" } }, "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -72,42 +72,37 @@ "docblock", "parser" ], - "time": "2017-12-06T07:11:42+00:00" + "time": "2015-08-31T12:32:49+00:00" }, { "name": "doctrine/cache", - "version": "v1.8.0", + "version": "v1.6.2", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57" + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57", - "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57", + "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", "shasum": "" }, "require": { - "php": "~7.1" + "php": "~5.5|~7.0" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "alcaeus/mongo-php-adapter": "^1.1", - "doctrine/coding-standard": "^4.0", - "mongodb/mongodb": "^1.1", - "phpunit/phpunit": "^7.0", - "predis/predis": "~1.0" - }, - "suggest": { - "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -142,12 +137,12 @@ } ], "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "https://www.doctrine-project.org", + "homepage": "http://www.doctrine-project.org", "keywords": [ "cache", "caching" ], - "time": "2018-08-21T18:01:43+00:00" + "time": "2017-07-22T12:49:21+00:00" }, { "name": "doctrine/collections", @@ -218,39 +213,33 @@ }, { "name": "doctrine/common", - "version": "v2.10.0", + "version": "v2.6.2", "source": { "type": "git", "url": "https://github.com/doctrine/common.git", - "reference": "30e33f60f64deec87df728c02b107f82cdafad9d" + "reference": "7bce00698899aa2c06fe7365c76e4d78ddb15fa3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/30e33f60f64deec87df728c02b107f82cdafad9d", - "reference": "30e33f60f64deec87df728c02b107f82cdafad9d", + "url": "https://api.github.com/repos/doctrine/common/zipball/7bce00698899aa2c06fe7365c76e4d78ddb15fa3", + "reference": "7bce00698899aa2c06fe7365c76e4d78ddb15fa3", "shasum": "" }, "require": { - "doctrine/annotations": "^1.0", - "doctrine/cache": "^1.0", - "doctrine/collections": "^1.0", - "doctrine/event-manager": "^1.0", - "doctrine/inflector": "^1.0", - "doctrine/lexer": "^1.0", - "doctrine/persistence": "^1.1", - "doctrine/reflection": "^1.0", - "php": "^7.1" + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~5.5|~7.0" }, "require-dev": { - "doctrine/coding-standard": "^1.0", - "phpunit/phpunit": "^6.3", - "squizlabs/php_codesniffer": "^3.0", - "symfony/phpunit-bridge": "^4.0.5" + "phpunit/phpunit": "~4.8|~5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.10.x-dev" + "dev-master": "2.7.x-dev" } }, "autoload": { @@ -282,48 +271,40 @@ { "name": "Johannes Schmitt", "email": "schmittjoh@gmail.com" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" } ], - "description": "PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, persistence interfaces, proxies, event system and much more.", - "homepage": "https://www.doctrine-project.org/projects/common.html", + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", "keywords": [ - "common", - "doctrine", - "php" + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" ], - "time": "2018-11-21T01:24:55+00:00" + "time": "2016-11-30T16:50:46+00:00" }, { "name": "doctrine/dbal", - "version": "v2.9.2", + "version": "v2.5.13", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9" + "reference": "729340d8d1eec8f01bff708e12e449a3415af873" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9", - "reference": "22800bd651c1d8d2a9719e2a3dc46d5108ebfcc9", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/729340d8d1eec8f01bff708e12e449a3415af873", + "reference": "729340d8d1eec8f01bff708e12e449a3415af873", "shasum": "" }, "require": { - "doctrine/cache": "^1.0", - "doctrine/event-manager": "^1.0", - "ext-pdo": "*", - "php": "^7.1" + "doctrine/common": ">=2.4,<2.8-dev", + "php": ">=5.3.2" }, "require-dev": { - "doctrine/coding-standard": "^5.0", - "jetbrains/phpstorm-stubs": "^2018.1.2", - "phpstan/phpstan": "^0.10.1", - "phpunit/phpunit": "^7.4", - "symfony/console": "^2.0.5|^3.0|^4.0", - "symfony/phpunit-bridge": "^3.4.5|^4.0.5" + "phpunit/phpunit": "4.*", + "symfony/console": "2.*||^3.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -334,13 +315,12 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.9.x-dev", - "dev-develop": "3.0.x-dev" + "dev-master": "2.5.x-dev" } }, "autoload": { - "psr-4": { - "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + "psr-0": { + "Doctrine\\DBAL\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -365,93 +345,15 @@ "email": "jonwage@gmail.com" } ], - "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", - "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", "keywords": [ - "abstraction", "database", "dbal", - "mysql", "persistence", - "pgsql", - "php", "queryobject" ], - "time": "2018-12-31T03:27:51+00:00" - }, - { - "name": "doctrine/event-manager", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/event-manager.git", - "reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/a520bc093a0170feeb6b14e9d83f3a14452e64b3", - "reference": "a520bc093a0170feeb6b14e9d83f3a14452e64b3", - "shasum": "" - }, - "require": { - "php": "^7.1" - }, - "conflict": { - "doctrine/common": "<2.9@dev" - }, - "require-dev": { - "doctrine/coding-standard": "^4.0", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\": "lib/Doctrine/Common" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "Doctrine Event Manager component", - "homepage": "https://www.doctrine-project.org/projects/event-manager.html", - "keywords": [ - "event", - "eventdispatcher", - "eventmanager" - ], - "time": "2018-06-11T11:59:03+00:00" + "time": "2017-07-22T20:44:48+00:00" }, { "name": "doctrine/inflector", @@ -522,32 +424,32 @@ }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=5.3,<8.0-DEV" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -572,7 +474,7 @@ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2015-06-14T21:17:01+00:00" }, { "name": "doctrine/lexer", @@ -630,40 +532,38 @@ }, { "name": "doctrine/orm", - "version": "v2.6.3", + "version": "v2.5.14", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "434820973cadf2da2d66e7184be370084cc32ca8" + "reference": "810a7baf81462a5ddf10e8baa8cb94b6eec02754" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/434820973cadf2da2d66e7184be370084cc32ca8", - "reference": "434820973cadf2da2d66e7184be370084cc32ca8", + "url": "https://api.github.com/repos/doctrine/orm/zipball/810a7baf81462a5ddf10e8baa8cb94b6eec02754", + "reference": "810a7baf81462a5ddf10e8baa8cb94b6eec02754", "shasum": "" }, "require": { - "doctrine/annotations": "~1.5", - "doctrine/cache": "~1.6", - "doctrine/collections": "^1.4", - "doctrine/common": "^2.7.1", - "doctrine/dbal": "^2.6", - "doctrine/instantiator": "~1.1", + "doctrine/cache": "~1.4", + "doctrine/collections": "~1.2", + "doctrine/common": ">=2.5-dev,<2.9-dev", + "doctrine/dbal": ">=2.5-dev,<2.7-dev", + "doctrine/instantiator": "^1.0.1", "ext-pdo": "*", - "php": "^7.1", - "symfony/console": "~3.0|~4.0" + "php": ">=5.4", + "symfony/console": "~2.5|~3.0|~4.0" }, "require-dev": { - "doctrine/coding-standard": "^1.0", - "phpunit/phpunit": "^6.5", - "squizlabs/php_codesniffer": "^3.2", - "symfony/yaml": "~3.4|~4.0" + "phpunit/phpunit": "~4.0", + "symfony/yaml": "~2.3|~3.0|~4.0" }, "suggest": { "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" }, "bin": [ - "bin/doctrine" + "bin/doctrine", + "bin/doctrine.php" ], "type": "library", "extra": { @@ -672,8 +572,8 @@ } }, "autoload": { - "psr-4": { - "Doctrine\\ORM\\": "lib/Doctrine/ORM" + "psr-0": { + "Doctrine\\ORM\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", @@ -696,10 +596,6 @@ { "name": "Jonathan Wage", "email": "jonwage@gmail.com" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" } ], "description": "Object-Relational-Mapper for PHP", @@ -708,164 +604,7 @@ "database", "orm" ], - "time": "2018-11-20T23:46:46+00:00" - }, - { - "name": "doctrine/persistence", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/persistence.git", - "reference": "c0f1c17602afc18b4cbd8e1c8125f264c9cf7d38" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/persistence/zipball/c0f1c17602afc18b4cbd8e1c8125f264c9cf7d38", - "reference": "c0f1c17602afc18b4cbd8e1c8125f264c9cf7d38", - "shasum": "" - }, - "require": { - "doctrine/annotations": "^1.0", - "doctrine/cache": "^1.0", - "doctrine/collections": "^1.0", - "doctrine/event-manager": "^1.0", - "doctrine/reflection": "^1.0", - "php": "^7.1" - }, - "conflict": { - "doctrine/common": "<2.10@dev" - }, - "require-dev": { - "doctrine/coding-standard": "^5.0", - "phpstan/phpstan": "^0.8", - "phpunit/phpunit": "^7.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\": "lib/Doctrine/Common" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.", - "homepage": "https://doctrine-project.org/projects/persistence.html", - "keywords": [ - "mapper", - "object", - "odm", - "orm", - "persistence" - ], - "time": "2018-11-21T00:33:13+00:00" - }, - { - "name": "doctrine/reflection", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/reflection.git", - "reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/reflection/zipball/02538d3f95e88eb397a5f86274deb2c6175c2ab6", - "reference": "02538d3f95e88eb397a5f86274deb2c6175c2ab6", - "shasum": "" - }, - "require": { - "doctrine/annotations": "^1.0", - "ext-tokenizer": "*", - "php": "^7.1" - }, - "require-dev": { - "doctrine/coding-standard": "^4.0", - "doctrine/common": "^2.8", - "phpstan/phpstan": "^0.9.2", - "phpstan/phpstan-phpunit": "^0.9.4", - "phpunit/phpunit": "^7.0", - "squizlabs/php_codesniffer": "^3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\": "lib/Doctrine/Common" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "Doctrine Reflection component", - "homepage": "https://www.doctrine-project.org/projects/reflection.html", - "keywords": [ - "reflection" - ], - "time": "2018-06-14T14:45:07+00:00" + "time": "2017-12-17T02:57:51+00:00" }, { "name": "friendica/json-ld", @@ -1094,6 +833,51 @@ ], "time": "2018-12-04T20:46:45+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v9.99.99", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, { "name": "phpseclib/phpseclib", "version": "2.0.14", @@ -1570,36 +1354,34 @@ }, { "name": "symfony/dependency-injection", - "version": "v4.2.3", + "version": "v3.4.22", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "72c14cbc0c27706b9b4c33b9cd7a280972ff4806" + "reference": "b514f5b765cf3e4a56e9d8ebacf14b117f7a0ee1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/72c14cbc0c27706b9b4c33b9cd7a280972ff4806", - "reference": "72c14cbc0c27706b9b4c33b9cd7a280972ff4806", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/b514f5b765cf3e4a56e9d8ebacf14b117f7a0ee1", + "reference": "b514f5b765cf3e4a56e9d8ebacf14b117f7a0ee1", "shasum": "" }, "require": { - "php": "^7.1.3", - "psr/container": "^1.0", - "symfony/contracts": "^1.0" + "php": "^5.5.9|>=7.0.8", + "psr/container": "^1.0" }, "conflict": { - "symfony/config": "<4.2", - "symfony/finder": "<3.4", + "symfony/config": "<3.3.7", + "symfony/finder": "<3.3", "symfony/proxy-manager-bridge": "<3.4", "symfony/yaml": "<3.4" }, "provide": { - "psr/container-implementation": "1.0", - "symfony/service-contracts-implementation": "1.0" + "psr/container-implementation": "1.0" }, "require-dev": { - "symfony/config": "~4.2", - "symfony/expression-language": "~3.4|~4.0", + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", "symfony/yaml": "~3.4|~4.0" }, "suggest": { @@ -1612,7 +1394,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1639,35 +1421,34 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2019-01-30T17:51:38+00:00" + "time": "2019-01-30T17:48:51+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.2.3", + "version": "v3.4.22", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1" + "reference": "ed5be1663fa66623b3a7004d5d51a14c4045399b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", - "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ed5be1663fa66623b3a7004d5d51a14c4045399b", + "reference": "ed5be1663fa66623b3a7004d5d51a14c4045399b", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/contracts": "^1.0" + "php": "^5.5.9|>=7.0.8" }, "conflict": { - "symfony/dependency-injection": "<3.4" + "symfony/dependency-injection": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -1676,7 +1457,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1703,34 +1484,34 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-01-16T20:35:37+00:00" + "time": "2019-01-16T13:27:11+00:00" }, { "name": "symfony/http-foundation", - "version": "v4.2.3", + "version": "v3.4.22", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "8d2318b73e0a1bc75baa699d00ebe2ae8b595a39" + "reference": "9a81d2330ea255ded06a69b4f7fb7804836e7a05" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8d2318b73e0a1bc75baa699d00ebe2ae8b595a39", - "reference": "8d2318b73e0a1bc75baa699d00ebe2ae8b595a39", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9a81d2330ea255ded06a69b4f7fb7804836e7a05", + "reference": "9a81d2330ea255ded06a69b4f7fb7804836e7a05", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.1" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php70": "~1.6" }, "require-dev": { - "predis/predis": "~1.0", - "symfony/expression-language": "~3.4|~4.0" + "symfony/expression-language": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1757,36 +1538,34 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-01-29T09:49:29+00:00" + "time": "2019-01-27T09:04:14+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.2.3", + "version": "v3.4.22", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "d56b1706abaa771eb6acd894c6787cb88f1dc97d" + "reference": "dc6bf17684b7120f7bf74fae85c9155506041002" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/d56b1706abaa771eb6acd894c6787cb88f1dc97d", - "reference": "d56b1706abaa771eb6acd894c6787cb88f1dc97d", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/dc6bf17684b7120f7bf74fae85c9155506041002", + "reference": "dc6bf17684b7120f7bf74fae85c9155506041002", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^5.5.9|>=7.0.8", "psr/log": "~1.0", - "symfony/contracts": "^1.0.2", - "symfony/debug": "~3.4|~4.0", - "symfony/event-dispatcher": "~4.1", - "symfony/http-foundation": "^4.1.1", + "symfony/debug": "^3.3.3|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~3.4.12|~4.0.12|^4.1.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/config": "<3.4", - "symfony/dependency-injection": "<4.2", - "symfony/translation": "<4.2", - "symfony/var-dumper": "<4.1.1", + "symfony/config": "<2.8", + "symfony/dependency-injection": "<3.4.10|<4.0.10,>=4", + "symfony/var-dumper": "<3.3", "twig/twig": "<1.34|<2.4,>=2" }, "provide": { @@ -1794,32 +1573,34 @@ }, "require-dev": { "psr/cache": "~1.0", - "symfony/browser-kit": "~3.4|~4.0", - "symfony/config": "~3.4|~4.0", - "symfony/console": "~3.4|~4.0", - "symfony/css-selector": "~3.4|~4.0", - "symfony/dependency-injection": "^4.2", - "symfony/dom-crawler": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/finder": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", + "symfony/browser-kit": "~2.8|~3.0|~4.0", + "symfony/class-loader": "~2.8|~3.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/console": "~2.8|~3.0|~4.0", + "symfony/css-selector": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "^3.4.10|^4.0.10", + "symfony/dom-crawler": "~2.8|~3.0|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/finder": "~2.8|~3.0|~4.0", + "symfony/process": "~2.8|~3.0|~4.0", "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0", - "symfony/templating": "~3.4|~4.0", - "symfony/translation": "~4.2", - "symfony/var-dumper": "^4.1.1" + "symfony/stopwatch": "~2.8|~3.0|~4.0", + "symfony/templating": "~2.8|~3.0|~4.0", + "symfony/translation": "~2.8|~3.0|~4.0", + "symfony/var-dumper": "~3.3|~4.0" }, "suggest": { "symfony/browser-kit": "", "symfony/config": "", "symfony/console": "", "symfony/dependency-injection": "", + "symfony/finder": "", "symfony/var-dumper": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -1846,7 +1627,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2019-02-03T12:47:33+00:00" + "time": "2019-02-03T12:22:50+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1965,6 +1746,65 @@ ], "time": "2018-09-21T13:07:52+00:00" }, + { + "name": "symfony/polyfill-php70", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/6b88000cdd431cd2e940caa2cb569201f3f84224", + "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "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 backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T06:26:08+00:00" + }, { "name": "symfony/psr-http-message-bridge", "version": "v1.1.0", @@ -2028,21 +1868,21 @@ }, { "name": "zendframework/zend-diactoros", - "version": "1.8.6", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "20da13beba0dde8fb648be3cc19765732790f46e" + "reference": "424a840dc3bedcdeea510b42e056c77c2d6c4bef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/20da13beba0dde8fb648be3cc19765732790f46e", - "reference": "20da13beba0dde8fb648be3cc19765732790f46e", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/424a840dc3bedcdeea510b42e056c77c2d6c4bef", + "reference": "424a840dc3bedcdeea510b42e056c77c2d6c4bef", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0", - "psr/http-message": "^1.0" + "php": "^5.4 || ^7.0", + "psr/http-message": "~1.0" }, "provide": { "psr/http-message-implementation": "1.0" @@ -2050,29 +1890,17 @@ "require-dev": { "ext-dom": "*", "ext-libxml": "*", - "php-http/psr7-integration-tests": "dev-master", - "phpunit/phpunit": "^5.7.16 || ^6.0.8 || ^7.2.7", - "zendframework/zend-coding-standard": "~1.0" + "phpunit/phpunit": "^4.6 || ^5.5", + "zendframework/zend-coding-standard": "~1.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev", - "dev-develop": "1.9.x-dev", - "dev-release-2.0": "2.0.x-dev" + "dev-master": "1.4-dev", + "dev-develop": "1.5-dev" } }, "autoload": { - "files": [ - "src/functions/create_uploaded_file.php", - "src/functions/marshal_headers_from_sapi.php", - "src/functions/marshal_method_from_sapi.php", - "src/functions/marshal_protocol_version_from_sapi.php", - "src/functions/marshal_uri_from_sapi.php", - "src/functions/normalize_server.php", - "src/functions/normalize_uploaded_files.php", - "src/functions/parse_cookie_header.php" - ], "psr-4": { "Zend\\Diactoros\\": "src/" } @@ -2088,7 +1916,7 @@ "psr", "psr-7" ], - "time": "2018-09-05T19:29:37+00:00" + "time": "2017-08-17T21:21:00+00:00" } ], "packages-dev": [ @@ -3230,5 +3058,7 @@ "platform": { "ext-json": "*" }, - "platform-dev": [] + "platform-dev": { + "ext-pdo": "*" + } } diff --git a/src/Activities/AcceptHandler.php b/src/Activities/AcceptHandler.php new file mode 100644 index 0000000..aff1189 --- /dev/null +++ b/src/Activities/AcceptHandler.php @@ -0,0 +1,81 @@ + 'handleInbox', + OutboxActivityEvent::NAME => 'handleOutbox', + ); + } + + public function __construct( ObjectsService $objectsService, + CollectionsService $collectionsService ) + { + $this->objectsService = $objectsService; + $this->collectionsService = $collectionsService; + } + + public function handleInbox( InboxActivityEvent $event ) + { + $activity = $event->getActivity(); + if ( $activity['type'] !== 'Accept' ) { + return; + } + // add to following collection + } + + public function handleOutbox( OutboxActivityEvent $event ) + { + $activity = $event->getActivity(); + if ( $activity['type'] !== 'Accept' ) { + return; + } + $request = $event->getRequest(); + // either there is a 'follow' key on the request, + // in which case this is an auto-accept dispatched from + // the FollowHandler so the Follow won't be in the database yet, + // or there isn't, in which case this is an ordinary Accept + // sent by a client and the Follow is in the database + $follow = $request->attributes->get( 'follow' ); + if ( ! $follow ) { + $followId = $activity['object']; + if ( is_array( $followId ) && array_key_exists( 'id', $followId ) ) { + $followId = $followId['id']; + } + if ( ! is_string( $followId ) ) { + return; + } + $follow = $this->objectsService->dereference( $followId )->asArray( -1 ); + } + if ( ! $follow || ! array_key_exists( 'object', $follow ) ) { + return; + } + $followObjectId = $follow['object']; + if ( is_array( $followObjectId ) && array_key_exists( 'id', $followObjectId ) ) { + $followObjectId = $followObjectId['id']; + } + $actor = $event->getActor(); + if ( $followObjectId !== $actor['id'] ) { + return; + } + $this->collectionsService->addItem( $actor['followers'], $activity['actor'] ); + } +} + diff --git a/src/Activities/DeleteHandler.php b/src/Activities/DeleteHandler.php index 45c7efc..6395373 100644 --- a/src/Activities/DeleteHandler.php +++ b/src/Activities/DeleteHandler.php @@ -1,9 +1,6 @@ contextProvider = $contextProvider; } - public function handleInbox( InboxActivityEvent $event, - $eventName, - EventDispatcher $eventDispatcher ) + + public function handleInbox(InboxActivityEvent $event, + /** @noinspection PhpUnusedParameterInspection */ + $eventName, + EventDispatcher $eventDispatcher ) { $activity = $event->getActivity(); if ( ! $activity['type'] === 'Follow' ) { diff --git a/src/Activities/InboxActivityEvent.php b/src/Activities/InboxActivityEvent.php index 998c8f3..2b70645 100644 --- a/src/Activities/InboxActivityEvent.php +++ b/src/Activities/InboxActivityEvent.php @@ -1,8 +1,6 @@ getRequest(); $actor = $event->getActor(); - $create = $this->makeCreate( $request, $object, $actor ); + $create = $this->makeCreate( $object, $actor ); $event->setActivity( $create ); } /** * Makes a new Create activity with $object as the object * - * @param Request $request The current request * @param array $object The object - * @param ActivityPubObject $actorId The actor creating the object + * @param ActivityPubObject $actor The actor creating the object * * @return array The Create activity */ - private function makeCreate( Request $request, array $object, + private function makeCreate( array $object, ActivityPubObject $actor ) { $create = array( diff --git a/src/Activities/OutboxActivityEvent.php b/src/Activities/OutboxActivityEvent.php index b975d3a..caa9c90 100644 --- a/src/Activities/OutboxActivityEvent.php +++ b/src/Activities/OutboxActivityEvent.php @@ -1,8 +1,6 @@ hasField( 'type' ) && ( $object['type'] === 'Collection' || $object['type'] === 'OrderedCollection' ) ) { - return $this->collectionsService->pageAndFilterCollection( $request, $object ); + $pagedCollection = $this->collectionsService->pageAndFilterCollection( $request, $object ); + return new JsonResponse( $pagedCollection ); } $response = new JsonResponse( $object->asArray() ); if ( $object->hasField( 'type' ) && diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 68bf982..1c7c0ce 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -7,6 +7,7 @@ use ActivityPub\Entities\ActivityPubObject; use ActivityPub\Objects\ObjectsService; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -40,6 +41,7 @@ class PostController * Either dispatches an inbox/outbox activity event or throws the appropriate * HTTP error. * @param Request $request The request + * @return Response */ public function handle( Request $request ) { @@ -112,15 +114,6 @@ class PostController return true; } - private function objectWithField( $name, $value ) - { - $results = $this->objectsService->query( array( $name => $value ) ); - if ( count( $results ) === 0 ) { - return false; - } - return $results[0]; - } - private function getUriWithoutQuery( Request $request ) { $uri = $request->getUri(); diff --git a/src/Crypto/HttpSignatureService.php b/src/Crypto/HttpSignatureService.php index 7d8d1e3..9206790 100644 --- a/src/Crypto/HttpSignatureService.php +++ b/src/Crypto/HttpSignatureService.php @@ -1,13 +1,13 @@ getSigningString( $request, $headers ); $keypair = RsaKeypair::fromPrivateKey( $privateKey ); - $signature = base64_encode( $keypair->sign( $signingString, 'rsa256' ) ); + $signature = base64_encode( $keypair->sign( $signingString, 'sha256' ) ); $headersStr = implode( ' ', $headers ); return "keyId=\"$keyId\"," . "algorithm=\"rsa-sha256\"," . @@ -127,7 +127,7 @@ class HttpSignatureService /** * Returns the signing string from the request * - * @param Request $request The request + * @param RequestInterface $request The request * @param array $headers The headers to use to generate the signing string * @return string The signing string */ diff --git a/src/Crypto/RsaKeypair.php b/src/Crypto/RsaKeypair.php index dfcaf46..4b89242 100644 --- a/src/Crypto/RsaKeypair.php +++ b/src/Crypto/RsaKeypair.php @@ -65,7 +65,7 @@ class RsaKeypair ); } $rsa = new RSA(); - $rsa->setHash( 'sha256' ); + $rsa->setHash( $hash ); $rsa->setSignatureMode(RSA::SIGNATURE_PKCS1); $rsa->loadKey( $this->privateKey ); return $rsa->sign( $data ); diff --git a/src/Entities/ActivityPubObject.php b/src/Entities/ActivityPubObject.php index 176a1b8..c52ec99 100644 --- a/src/Entities/ActivityPubObject.php +++ b/src/Entities/ActivityPubObject.php @@ -1,10 +1,12 @@ -hasField( 'items' ) ) { $items = new ActivityPubObject( $this->dateTimeProvider->getTime( 'collections-service.create' ) @@ -189,7 +196,7 @@ class CollectionsService $idx = $offset; $count = 0; while ( $count < $pageSize ) { - $item = $collectionItems->getFieldValue( strval( $idx ) ); + $item = $collectionItems->getFieldValue( $idx ); if ( ! $item ) { break; } @@ -225,14 +232,14 @@ class CollectionsService private function hasNextItem( Request $request, ActivityPubObject $collectionItems, $idx ) { - $next = $collectionItems->getFieldValue( strval( $idx ) ); + $next = $collectionItems->getFieldValue( $idx ); while ( $next ) { if ( is_string( $next ) || $this->authService->isAuthorized( $request, $next ) ) { return $idx; } $idx++; - $next = $collectionItems->getFieldValue( strval( $idx ) ); + $next = $collectionItems->getFieldValue( $idx ); } return false; } diff --git a/src/Objects/IdProvider.php b/src/Objects/IdProvider.php index 8c30fd7..dfa14d1 100644 --- a/src/Objects/IdProvider.php +++ b/src/Objects/IdProvider.php @@ -1,7 +1,6 @@ entityManager->flush(); return $object; - } + }/** @noinspection PhpDocMissingThrowsInspection */ /** - * Persists a field. + * Persists a field. * * If the field is an array, persist it as a child object * * @param ActivityPubObject $object * @param string $fieldName * @param string|array $fieldValue - * + * @param string $context */ private function persistField( $object, $fieldName, $fieldValue, $context = 'objects-service.create' ) { diff --git a/src/Utils/HeaderUtils.php b/src/Utils/HeaderUtils.php new file mode 100644 index 0000000..aa8ab49 --- /dev/null +++ b/src/Utils/HeaderUtils.php @@ -0,0 +1,220 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace ActivityPub\Utils; +/** + * HTTP header utility functions. + * + * @author Christian Schmidt + */ +class HeaderUtils +{ + const DISPOSITION_ATTACHMENT = 'attachment'; + const DISPOSITION_INLINE = 'inline'; + /** + * This class should not be instantiated. + */ + private function __construct() + { + } + /** + * Splits an HTTP header by one or more separators. + * + * Example: + * + * HeaderUtils::split("da, en-gb;q=0.8", ",;") + * // => ['da'], ['en-gb', 'q=0.8']] + * + * @param string $header HTTP header value + * @param string $separators List of characters to split on, ordered by + * precedence, e.g. ",", ";=", or ",;=" + * + * @return array Nested array with as many levels as there are characters in + * $separators + */ + public static function split($header, $separators) + { + $quotedSeparators = preg_quote($separators, '/'); + preg_match_all(' + / + (?!\s) + (?: + # quoted-string + "(?:[^"\\\\]|\\\\.)*(?:"|\\\\|$) + | + # token + [^"'.$quotedSeparators.']+ + )+ + (?['.$quotedSeparators.']) + \s* + /x', trim($header), $matches, PREG_SET_ORDER); + return self::groupParts($matches, $separators); + } + + /** + * Combines an array of arrays into one associative array. + * + * Each of the nested arrays should have one or two elements. The first + * value will be used as the keys in the associative array, and the second + * will be used as the values, or true if the nested array only contains one + * element. Array keys are lowercased. + * + * Example: + * + * HeaderUtils::combine([["foo", "abc"], ["bar"]]) + * // => ["foo" => "abc", "bar" => true] + * @param array $parts + * @return array + */ + public static function combine(array $parts) + { + $assoc = []; + foreach ($parts as $part) { + $name = strtolower($part[0]); + if (isset($part[1])) { + $value = $part[1]; + } else { + $value = true; + } + $assoc[$name] = $value; + } + return $assoc; + } + + /** + * Joins an associative array into a string for use in an HTTP header. + * + * The key and value of each entry are joined with "=", and all entries + * are joined with the specified separator and an additional space (for + * readability). Values are quoted if necessary. + * + * Example: + * + * HeaderUtils::toString(["foo" => "abc", "bar" => true, "baz" => "a b c"], ",") + * // => 'foo=abc, bar, baz="a b c"' + * @param array $assoc + * @param $separator + * @return string + */ + public static function toString(array $assoc, $separator) + { + $parts = []; + foreach ($assoc as $name => $value) { + if (true === $value) { + $parts[] = $name; + } else { + $parts[] = $name.'='.self::quote($value); + } + } + return implode($separator.' ', $parts); + } + + /** + * Encodes a string as a quoted string, if necessary. + * + * If a string contains characters not allowed by the "token" construct in + * the HTTP specification, it is backslash-escaped and enclosed in quotes + * to match the "quoted-string" construct. + * @param $s + * @return string + */ + public static function quote($s) + { + if (preg_match('/^[a-z0-9!#$%&\'*.^_`|~-]+$/i', $s)) { + return $s; + } + return '"'.addcslashes($s, '"\\"').'"'; + } + + /** + * Decodes a quoted string. + * + * If passed an unquoted string that matches the "token" construct (as + * defined in the HTTP specification), it is passed through verbatimly. + * @param $s + * @return string|string[]|null + */ + public static function unquote($s) + { + return preg_replace('/\\\\(.)|"/', '$1', $s); + } + /** + * Generates a HTTP Content-Disposition field-value. + * + * @param string $disposition One of "inline" or "attachment" + * @param string $filename A unicode string + * @param string $filenameFallback A string containing only ASCII characters that + * is semantically equivalent to $filename. If the filename is already ASCII, + * it can be omitted, or just copied from $filename + * + * @return string A string suitable for use as a Content-Disposition field-value + * + * @throws \InvalidArgumentException + * + * @see RFC 6266 + */ + public static function makeDisposition($disposition, $filename, $filenameFallback = '') + { + if (!\in_array($disposition, [self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE])) { + throw new \InvalidArgumentException(sprintf('The disposition must be either "%s" or "%s".', self::DISPOSITION_ATTACHMENT, self::DISPOSITION_INLINE)); + } + if ('' === $filenameFallback) { + $filenameFallback = $filename; + } + // filenameFallback is not ASCII. + if (!preg_match('/^[\x20-\x7e]*$/', $filenameFallback)) { + throw new \InvalidArgumentException('The filename fallback must only contain ASCII characters.'); + } + // percent characters aren't safe in fallback. + if (false !== strpos($filenameFallback, '%')) { + throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.'); + } + // path separators aren't allowed in either. + if (false !== strpos($filename, '/') || false !== strpos($filename, '\\') || false !== strpos($filenameFallback, '/') || false !== strpos($filenameFallback, '\\')) { + throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.'); + } + $params = ['filename' => $filenameFallback]; + if ($filename !== $filenameFallback) { + $params['filename*'] = "utf-8''".rawurlencode($filename); + } + return $disposition.'; '.self::toString($params, ';'); + } + private static function groupParts(array $matches, $separators) + { + $separator = $separators[0]; + $partSeparators = substr($separators, 1); + $i = 0; + $partMatches = []; + foreach ($matches as $match) { + if (isset($match['separator']) && $match['separator'] === $separator) { + ++$i; + } else { + $partMatches[$i][] = $match; + } + } + $parts = []; + if ($partSeparators) { + foreach ($partMatches as $matches) { + $parts[] = self::groupParts($matches, $partSeparators); + } + } else { + foreach ($partMatches as $matches) { + $parts[] = self::unquote($matches[0][0]); + } + } + return $parts; + } +} diff --git a/src/Utils/SimpleDateTimeProvider.php b/src/Utils/SimpleDateTimeProvider.php index f0d746d..223c4db 100644 --- a/src/Utils/SimpleDateTimeProvider.php +++ b/src/Utils/SimpleDateTimeProvider.php @@ -1,11 +1,12 @@ -assertTrue( false ); + } + + public function testHandleOutbox() + { + // TODO implement me + $this->assertTrue( false ); + } +} + diff --git a/test/Activities/CreateHandlerTest.php b/test/Activities/CreateHandlerTest.php index f1e333d..7600bb8 100644 --- a/test/Activities/CreateHandlerTest.php +++ b/test/Activities/CreateHandlerTest.php @@ -18,6 +18,9 @@ use Symfony\Component\HttpFoundation\Request; class CreateHandlerTest extends APTestCase { + /** + * @var EventDispatcher + */ private $eventDispatcher; public function setUp() diff --git a/test/Activities/FollowHandlerTest.php b/test/Activities/FollowHandlerTest.php index 0e8a63b..f948ffd 100644 --- a/test/Activities/FollowHandlerTest.php +++ b/test/Activities/FollowHandlerTest.php @@ -81,7 +81,7 @@ class FollowHandlerTest extends APTestCase 'type' => 'Follow', 'object' => 'https://example.com/actor/2', ); - $eventDispatcher->addListener( OutboxActivityEvent::NAME, function( $event ) + $eventDispatcher->addListener( OutboxActivityEvent::NAME, function() use ( &$outboxDispatched ) { $outboxDispatched = true; diff --git a/test/ActivityPubTest.php b/test/ActivityPubTest.php index c1575f4..6c45213 100644 --- a/test/ActivityPubTest.php +++ b/test/ActivityPubTest.php @@ -1,4 +1,5 @@ -setExpectedException( \PHPUnit_Framework_Error::class ); - $verified = $keypair->verify( $data, $signature ); + $keypair->verify( $data, $signature ); } public function testItReturnsNotVerifiedForValidButWrongSignature() diff --git a/test/Entities/EntityTest.php b/test/Entities/EntityTest.php index 441c629..caee654 100644 --- a/test/Entities/EntityTest.php +++ b/test/Entities/EntityTest.php @@ -1,8 +1,9 @@ -entityManager->flush(); $newPrivateKey = 'a new private key'; $object->setPrivateKey( $newPrivateKey ); - $this->entityManager->persiste( $object ); + $this->entityManager->persist( $object ); $this->entityManager->flush(); $now = $this->getTime( 'objects-service.create' ); $expected = new ArrayDataSet( array( diff --git a/test/Objects/CollectionsServiceTest.php b/test/Objects/CollectionsServiceTest.php index 1fa2ddb..39f00ef 100644 --- a/test/Objects/CollectionsServiceTest.php +++ b/test/Objects/CollectionsServiceTest.php @@ -2,7 +2,6 @@ namespace ActivityPub\Test\Objects; use ActivityPub\Utils\SimpleDateTimeProvider; -use Exception; use ActivityPub\Auth\AuthService; use ActivityPub\Objects\ContextProvider; use ActivityPub\Objects\CollectionsService; diff --git a/test/Objects/IdProviderTest.php b/test/Objects/IdProviderTest.php index f756fa0..cf40374 100644 --- a/test/Objects/IdProviderTest.php +++ b/test/Objects/IdProviderTest.php @@ -57,7 +57,6 @@ class IdProviderTest extends APTestCase ); $idProvider = new IdProvider( $this->objectsService, $randomProvider, 'ap' ); $request = Request::create( 'https://example.com' ); - $id = ''; if ( array_key_exists( 'path', $testCase ) ) { $id = $idProvider->getId( $request, $testCase['path'] ); } else { diff --git a/test/Objects/ObjectsServiceTest.php b/test/Objects/ObjectsServiceTest.php index f238bb5..ab125ac 100644 --- a/test/Objects/ObjectsServiceTest.php +++ b/test/Objects/ObjectsServiceTest.php @@ -1,16 +1,16 @@ - 'This is a note', ); $now = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $expected = new ArrayDataSet( array( 'objects' => array( array( 'id' => 1, 'created' => $now, 'lastUpdated' => $now ) @@ -166,7 +178,7 @@ class ObjectsServiceTest extends SQLiteTestCase ), ); $now = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $expected = new ArrayDataSet( array( 'objects' => array( array( 'id' => 1, 'created' => $now, 'lastUpdated' => $now ), @@ -267,7 +279,7 @@ class ObjectsServiceTest extends SQLiteTestCase ), ); $now = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $expected = new ArrayDataSet( array( 'objects' => array( array( 'id' => 1, 'created' => $now, 'lastUpdated' => $now ), @@ -366,7 +378,7 @@ class ObjectsServiceTest extends SQLiteTestCase ), ); $now = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $expected = new ArrayDataSet( array( 'objects' => array( array( 'id' => 1, 'created' => $now, 'lastUpdated' => $now ), @@ -535,7 +547,7 @@ class ObjectsServiceTest extends SQLiteTestCase 'type' => 'Collection', 'items' => array( "https://example.com/items/1" ), ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $query = array( 'id' => 'https://example.com/collections/1' ); @@ -782,7 +794,7 @@ class ObjectsServiceTest extends SQLiteTestCase 'type' => 'Note', 'content' => 'This is a note' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $found = $this->objectsService->dereference( 'https://example.com/note/2' ); $this->assertNull( $found ); } @@ -795,7 +807,7 @@ class ObjectsServiceTest extends SQLiteTestCase 'content' => 'This is a note' ); $createTime = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $update = array( 'content' => 'This note has been updated' ); $updateTime = $this->getTime( 'objects-service.update' ); $this->objectsService->update( 'https://example.com/notes/1', $update ); @@ -860,7 +872,7 @@ class ObjectsServiceTest extends SQLiteTestCase ), ); $createTime = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $update = array( 'attributedTo' => array( 'id' => 'https://example.com/actors/2', ) ); @@ -965,7 +977,7 @@ class ObjectsServiceTest extends SQLiteTestCase ), ); $createTime = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $update = array( 'likes' => array( 'https://example.com/likes/3', 'https://example.com/likes/4', @@ -1062,7 +1074,7 @@ class ObjectsServiceTest extends SQLiteTestCase 'content' => 'This is a note' ); $createTime = $this->getTime( 'objects-service.create' ); - $object = $this->objectsService->persist( $fields ); + $this->objectsService->persist( $fields ); $update = array( 'content' => null ); $updateTime = $this->getTime( 'objects-service.update' ); $this->objectsService->update( 'https://example.com/notes/1', $update ); @@ -1114,7 +1126,6 @@ class ObjectsServiceTest extends SQLiteTestCase 'type' => 'Note', 'content' => 'This is a note', ); - $now = $this->getTime( 'objects-service.create' ); $object = $this->objectsService->persist( $fields ); $this->assertEquals( $object['content'], 'This is a note' ); $this->assertNull( $object['attributedTo'] ); @@ -1127,7 +1138,6 @@ class ObjectsServiceTest extends SQLiteTestCase 'type' => 'Note', 'content' => 'This is a note', ); - $now = $this->getTime( 'objects-service.create' ); $object = $this->objectsService->persist( $fields ); $this->setExpectedException( BadMethodCallException::class ); $object['content'] = 'This should break'; @@ -1140,7 +1150,6 @@ class ObjectsServiceTest extends SQLiteTestCase 'type' => 'Note', 'content' => 'This is a note', ); - $now = $this->getTime( 'objects-service.create' ); $object = $this->objectsService->persist( $fields ); $this->setExpectedException( BadMethodCallException::class ); unset( $object['content'] ); @@ -1156,7 +1165,6 @@ class ObjectsServiceTest extends SQLiteTestCase 'id' => 'https://example.com/actor/1' ), ); - $now = $this->getTime( 'objects-service.create' ); $object = $this->objectsService->persist( $fields ); $this->assertEquals( $object['content'], 'This is a note' ); $this->assertInstanceOf( ActivityPubObject::class, $object['attributedTo'] ); @@ -1271,9 +1279,10 @@ class ObjectsServiceTest extends SQLiteTestCase if ( array_key_exists( 'expectedQueryResults', $testCase ) ) { foreach ( $testCase['expectedQueryResults'] as $expectedQueryResult ) { $result = array_map( - function( $obj ) { return $obj->asArray(); }, + function( ActivityPubObject $obj ) { return $obj->asArray(); }, $this->objectsService->query( $expectedQueryResult['query'] ) ); + $this->assertEquals( $expectedQueryResult['expectedResult'], $result ); } } } diff --git a/test/TestConfig/SQLiteTestCase.php b/test/TestConfig/SQLiteTestCase.php index eb0651b..aeaa6dc 100644 --- a/test/TestConfig/SQLiteTestCase.php +++ b/test/TestConfig/SQLiteTestCase.php @@ -1,9 +1,12 @@ -fixedTime = $time; } - public function setTargetObject( ActivityPubObject $targetObject, $time = null ) + public function setTargetObject( ActivityPubObject $targetObject, DateTime $time = null ) { parent::setTargetObject( $targetObject, $time ); $this->lastUpdated = $this->fixedTime; } - public function setValue( $value, $time = null ) + public function setValue( $value, DateTime $time = null ) { parent::setValue( $value, $time ); $this->lastUpdated = $this->fixedTime; } - protected function setCreated( $timestamp ) + protected function setCreated( DateTime $timestamp ) { // don't set created } - protected function setLastupdated( $timestamp ) + protected function setLastupdated( DateTime $timestamp ) { // don't set lastUpdated } diff --git a/test/bootstrap.php b/test/bootstrap.php index 24680c6..bb7c5aa 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,4 +1,5 @@ -