provide optional salmon signatures for AP entities

This commit is contained in:
zotlabs 2017-07-18 21:16:18 -07:00
parent b52a968c74
commit 6103c30184
2 changed files with 18 additions and 5 deletions

View File

@ -11,7 +11,8 @@ class Ap_probe extends \Zotlabs\Web\Controller {
$o .= '<h3>ActivityPub Probe Diagnostic</h3>';
$o .= '<form action="ap_probe" method="get">';
$o .= 'Lookup URI: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" />';
$o .= 'Lookup URI: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" /><br>';
$o .= 'Request Signed version: <input type=checkbox name="magenv" value="1" ><br>';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
@ -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 .= '<pre>' . str_replace('\\','',jindent($x['body'])) . '</pre>';
}

View File

@ -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',[]);