Added doxygen data
This commit is contained in:
parent
f7d7d94111
commit
9c62727e1d
2 changed files with 62 additions and 0 deletions
|
@ -26,6 +26,13 @@ use Friendica\Protocol\ActivityPub;
|
||||||
class HTTPSignature
|
class HTTPSignature
|
||||||
{
|
{
|
||||||
// See draft-cavage-http-signatures-08
|
// See draft-cavage-http-signatures-08
|
||||||
|
/**
|
||||||
|
* @brief Verifies a magic request
|
||||||
|
*
|
||||||
|
* @param $key
|
||||||
|
*
|
||||||
|
* @return array with verification data
|
||||||
|
*/
|
||||||
public static function verifyMagic($key)
|
public static function verifyMagic($key)
|
||||||
{
|
{
|
||||||
$headers = null;
|
$headers = null;
|
||||||
|
@ -262,6 +269,13 @@ class HTTPSignature
|
||||||
* Functions for ActivityPub
|
* 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)
|
public static function transmit($data, $target, $uid)
|
||||||
{
|
{
|
||||||
$owner = User::getOwnerDataById($uid);
|
$owner = User::getOwnerDataById($uid);
|
||||||
|
@ -294,6 +308,14 @@ class HTTPSignature
|
||||||
logger('Transmit to ' . $target . ' returned ' . $return_code);
|
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)
|
public static function getSigner($content, $http_headers)
|
||||||
{
|
{
|
||||||
$object = json_decode($content, true);
|
$object = json_decode($content, true);
|
||||||
|
@ -390,6 +412,14 @@ class HTTPSignature
|
||||||
return $key['url'];
|
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)
|
private static function fetchKey($id, $actor)
|
||||||
{
|
{
|
||||||
$url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id);
|
$url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id);
|
||||||
|
|
|
@ -12,6 +12,13 @@ use digitalbazaar\jsonld as DBJsonLD;
|
||||||
*/
|
*/
|
||||||
class JsonLD
|
class JsonLD
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief Loader for LD-JSON validation
|
||||||
|
*
|
||||||
|
* @param $url
|
||||||
|
*
|
||||||
|
* @return the loaded data
|
||||||
|
*/
|
||||||
public static function documentLoader($url)
|
public static function documentLoader($url)
|
||||||
{
|
{
|
||||||
$recursion = 0;
|
$recursion = 0;
|
||||||
|
@ -40,6 +47,13 @@ class JsonLD
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Normalises a given JSON array
|
||||||
|
*
|
||||||
|
* @param array $json
|
||||||
|
*
|
||||||
|
* @return normalized JSON string
|
||||||
|
*/
|
||||||
public static function normalize($json)
|
public static function normalize($json)
|
||||||
{
|
{
|
||||||
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
|
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
|
||||||
|
@ -49,6 +63,13 @@ class JsonLD
|
||||||
return jsonld_normalize($jsonobj, array('algorithm' => 'URDNA2015', 'format' => 'application/nquads'));
|
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)
|
public static function compact($json)
|
||||||
{
|
{
|
||||||
jsonld_set_document_loader('Friendica\Util\JsonLD::documentLoader');
|
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);
|
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)
|
public static function fetchElement($array, $element, $key, $type = null, $type_value = null)
|
||||||
{
|
{
|
||||||
if (empty($array)) {
|
if (empty($array)) {
|
||||||
|
|
Loading…
Reference in a new issue