From 6103c301848105a3bca3de81e9982276b2c38d76 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 18 Jul 2017 21:16:18 -0700 Subject: [PATCH] provide optional salmon signatures for AP entities --- Zotlabs/Module/Ap_probe.php | 15 ++++++++++----- include/feedutils.php | 8 ++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Zotlabs/Module/Ap_probe.php b/Zotlabs/Module/Ap_probe.php index 4649914d5..f788fa73a 100644 --- a/Zotlabs/Module/Ap_probe.php +++ b/Zotlabs/Module/Ap_probe.php @@ -11,7 +11,8 @@ class Ap_probe extends \Zotlabs\Web\Controller { $o .= '

ActivityPub Probe Diagnostic

'; $o .= '
'; - $o .= 'Lookup URI: '; + $o .= 'Lookup URI:
'; + $o .= 'Request Signed version:
'; $o .= '
'; $o .= '

'; @@ -19,11 +20,15 @@ class Ap_probe extends \Zotlabs\Web\Controller { if(x($_GET,'addr')) { $addr = $_GET['addr']; - $redirects = 0; - $x = z_fetch_url($addr,true,$redirects, - [ 'headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); -logger('fetch: ' . print_r($x,true)); + if($_GET['magenv']) { + $headers = 'Accept: application/magic-envelope+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; + } + else { + $headers = 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"'; + } + $redirects = 0; + $x = z_fetch_url($addr,true,$redirects, [ 'headers' => [ $headers ]]); if($x['success']) $o .= '
' . str_replace('\\','',jindent($x['body'])) . '
'; } diff --git a/include/feedutils.php b/include/feedutils.php index daab1a741..5d537553f 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1973,6 +1973,14 @@ function asencode_person($p) { if(array_key_exists('channel_id',$p)) { $ret['inbox'] = z_root() . '/inbox/' . $p['channel_address']; $ret['outbox'] = z_root() . '/outbox/' . $p['channel_address']; + $ret['me:magic_keys'] = [ + [ + 'value' => salmon_key($p['channel_pubkey']), + 'key_id' => base64url_encode(hash('sha256',salmon_key($p['channel_pubkey'])),true) + ] + ]; + + } else { $collections = get_xconfig($p['xchan_hash'],'activitystreams','collections',[]);