From 9c62727e1dc11fe9fdd63949840ad36c86ee7485 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 26 Sep 2018 22:02:14 +0000 Subject: [PATCH] Added doxygen data --- src/Util/HTTPSignature.php | 30 ++++++++++++++++++++++++++++++ src/Util/JsonLD.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 695ef3fb31..7adaa82f78 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -26,6 +26,13 @@ use Friendica\Protocol\ActivityPub; class HTTPSignature { // See draft-cavage-http-signatures-08 + /** + * @brief Verifies a magic request + * + * @param $key + * + * @return array with verification data + */ public static function verifyMagic($key) { $headers = null; @@ -262,6 +269,13 @@ class HTTPSignature * Functions for ActivityPub */ + /** + * @brief Transmit given data to a target for a user + * + * @param $data + * @param $target + * @param $uid + */ public static function transmit($data, $target, $uid) { $owner = User::getOwnerDataById($uid); @@ -294,6 +308,14 @@ class HTTPSignature logger('Transmit to ' . $target . ' returned ' . $return_code); } + /** + * @brief Gets a signer from a given HTTP request + * + * @param $content + * @param $http_headers + * + * @return signer string + */ public static function getSigner($content, $http_headers) { $object = json_decode($content, true); @@ -390,6 +412,14 @@ class HTTPSignature return $key['url']; } + /** + * @brief fetches a key for a given id and actor + * + * @param $id + * @param $actor + * + * @return array with actor url and public key + */ private static function fetchKey($id, $actor) { $url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id); diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index d3c101120b..4917c3c015 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -12,6 +12,13 @@ use digitalbazaar\jsonld as DBJsonLD; */ class JsonLD { + /** + * @brief Loader for LD-JSON validation + * + * @param $url + * + * @return the loaded data + */ public static function documentLoader($url) { $recursion = 0; @@ -40,6 +47,13 @@ class JsonLD return $data; } + /** + * @brief Normalises a given JSON array + * + * @param array $json + * + * @return normalized JSON string + */ public static function normalize($json) { jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader'); @@ -49,6 +63,13 @@ class JsonLD return jsonld_normalize($jsonobj, array('algorithm' => 'URDNA2015', 'format' => 'application/nquads')); } + /** + * @brief Compacts a given JSON array + * + * @param array $json + * + * @return comacted JSON array + */ public static function compact($json) { jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader'); @@ -66,6 +87,17 @@ class JsonLD return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true); } + /** + * @brief Fetches an element from a JSON array + * + * @param $array + * @param $element + * @param $key + * @param $type + * @param $type_value + * + * @return fetched element + */ public static function fetchElement($array, $element, $key, $type = null, $type_value = null) { if (empty($array)) {