- // Check the digest when it is part of the signed data
- if (in_array('digest', $sig_block['headers'])) {
- $digest = explode('=', $headers['digest'], 2);
- if ($digest[0] === 'SHA-256') {
- $hashalg = 'sha256';
- }
- if ($digest[0] === 'SHA-512') {
- $hashalg = 'sha512';
- }
-
- /// @todo add all hashes from the rfc
-
- if (!empty($hashalg) && base64_encode(hash($hashalg, $content, true)) != $digest[1]) {
- return false;
- }
- }
-
- // Check the content-length when it is part of the signed data
- if (in_array('content-length', $sig_block['headers'])) {
- if (strlen($content) != $headers['content-length']) {
- return false;
- }
- }
+ $apcontact = [];
+ $apcontact['url'] = $data['id'];
+ $apcontact['uuid'] = defaults($data, 'uuid', null);
+ $apcontact['type'] = defaults($data, 'type', null);
+ $apcontact['following'] = defaults($data, 'following', null);
+ $apcontact['followers'] = defaults($data, 'followers', null);
+ $apcontact['inbox'] = defaults($data, 'inbox', null);
+ $apcontact['outbox'] = defaults($data, 'outbox', null);
+ $apcontact['sharedinbox'] = JsonLD::fetchElement($data, 'endpoints', 'sharedInbox');
+ $apcontact['nick'] = defaults($data, 'preferredUsername', null);
+ $apcontact['name'] = defaults($data, 'name', $apcontact['nick']);
+ $apcontact['about'] = defaults($data, 'summary', '');
+ $apcontact['photo'] = JsonLD::fetchElement($data, 'icon', 'url');
+ $apcontact['alias'] = JsonLD::fetchElement($data, 'url', 'href');
+
+ $parts = parse_url($apcontact['url']);
+ unset($parts['scheme']);
+ unset($parts['path']);
+ $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts));