some experimental work for Nomad/v12 with an ultimate goal of bringing nomadic identity to ActivityPub - since nobody else seems to be able to figure out how to do it after 5 years. Also seeing if I can streamline the portable_id generation process dramatically. Hint: did: can be used as an alternate or internal identifier, but did: isn't going to get us there.

This commit is contained in:
Mike Macgirvin 2023-09-03 08:17:39 +10:00
parent 9d13f714ee
commit 4f4c6c30bc
5 changed files with 65 additions and 4 deletions

View file

@ -8,6 +8,42 @@ class Signature extends ASObject
public $creator; public $creator;
public $signatureValue; public $signatureValue;
/**
* @return mixed
*/
public function getCreator()
{
return $this->creator;
}
/**
* @param mixed $creator
* @return Signature
*/
public function setCreator($creator)
{
$this->creator = $creator;
return $this;
}
/**
* @return mixed
*/
public function getSignatureValue()
{
return $this->signatureValue;
}
/**
* @param mixed $signatureValue
* @return Signature
*/
public function setSignatureValue($signatureValue)
{
$this->signatureValue = $signatureValue;
return $this;
}
/** /**
* @return mixed * @return mixed
*/ */

View file

@ -8,6 +8,8 @@ use Code\ActivityStreams\Actor;
use Code\ActivityStreams\ASObject; use Code\ActivityStreams\ASObject;
use Code\ActivityStreams\Link; use Code\ActivityStreams\Link;
use Code\ActivityStreams\Place; use Code\ActivityStreams\Place;
use Code\ActivityStreams\UnhandledElementException;
use Code\Nomad\Location;
use Code\Nomad\Profile; use Code\Nomad\Profile;
use Code\Web\HTTPHeaders; use Code\Web\HTTPHeaders;
use Code\Web\HTTPSig; use Code\Web\HTTPSig;
@ -1617,6 +1619,9 @@ class Activity
} }
/**
* @throws UnhandledElementException
*/
public static function encode_person($p, $extended = true, $activitypub = false) public static function encode_person($p, $extended = true, $activitypub = false)
{ {
@ -1738,6 +1743,7 @@ class Activity
// map other nomadic identities linked with this channel // map other nomadic identities linked with this channel
$locations = []; $locations = [];
$nomadicLocations = [];
$locs = Libzot::encode_locations($c); $locs = Libzot::encode_locations($c);
if ($locs) { if ($locs) {
foreach ($locs as $loc) { foreach ($locs as $loc) {
@ -1745,8 +1751,24 @@ class Activity
$locations[] = $loc['id_url']; $locations[] = $loc['id_url'];
} }
} }
}
foreach ($locs as $loc) {
$loc = new Location($loc);
$sig = explode('.', $loc->getUrlSig(), 2);
$entry = [
'id' => $loc->getIdUrl(),
'url' => $loc->getIdUrl(),
'signature' => [
'id' => $loc->getIdUrl() . '?operation=getkey',
'nonce' => random_string(),
'creator' => $loc->getIdUrl(),
'signature' => base64_encode(Crypto::sign($loc->getIdUrl(), $c['channel_prvkey'])),
],
];
$nomadicLocations[] = $entry;
}
}
// $ret['nomadicLocations'] = $nomadicLocations;
if ($locations) { if ($locations) {
if (count($locations) === 1) { if (count($locations) === 1) {
$locations = array_shift($locations); $locations = array_shift($locations);
@ -1755,6 +1777,8 @@ class Activity
$ret['alsoKnownAs'] = $locations; $ret['alsoKnownAs'] = $locations;
} }
// To move your followers from a Mastodon account, // To move your followers from a Mastodon account,
// visit https://$yoursite/pconfig/system/movefrom // visit https://$yoursite/pconfig/system/movefrom
// And set the value to the URL of your Mastodon profile. // And set the value to the URL of your Mastodon profile.
@ -4768,6 +4792,7 @@ class Activity
'wall' => 'sm:wall', 'wall' => 'sm:wall',
'capabilities' => 'litepub:capabilities', 'capabilities' => 'litepub:capabilities',
'acceptsJoins' => 'litepub:acceptsJoins', 'acceptsJoins' => 'litepub:acceptsJoins',
'nomadicLocations' => 'nomad:nomadicLocations',
'Hashtag' => 'as:Hashtag', 'Hashtag' => 'as:Hashtag',
'canReply' => 'toot:canReply', 'canReply' => 'toot:canReply',
'approval' => 'toot:approval', 'approval' => 'toot:approval',

View file

@ -85,7 +85,7 @@ class Libzot
/* Only search for active hublocs - e.g. those that haven't been marked deleted */ /* Only search for active hublocs - e.g. those that haven't been marked deleted */
$ret = q( $ret = q(
"select * from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 order by hubloc_url ", "select * from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0 order by hubloc_primary DESC, hubloc_url ",
dbesc($hash) dbesc($hash)
); );

View file

@ -88,7 +88,7 @@ class Inbox extends Controller
if (!$AS->is_valid()) { if (!$AS->is_valid()) {
if ($AS->deleted) { if ($AS->deleted) {
// process mastodon user deletion activities, but only if we can validate the signature // process mastodon user deletion activities, but only if we can validate the signature
if ($hsig['header_valid'] && $hsig['content_valid'] && $hsig['portable_id']) { if ($hsig['portable_id']) {
logger('removing deleted actor'); logger('removing deleted actor');
remove_all_xchan_resources($hsig['portable_id']); remove_all_xchan_resources($hsig['portable_id']);
} else { } else {

View file

@ -1,6 +1,6 @@
An open source fediverse server with a long history of innovation. See [FEATURES](https://codeberg.org/streams/streams/src/branch/dev/FEATURES.md). An open source fediverse server with a long history of innovation. See [FEATURES](https://codeberg.org/streams/streams/src/branch/dev/FEATURES.md).
This software is dedicated to the public domain to the extent permissable by law and is not associated with any consumer brand or product. This software is dedicated to the public domain to the extent permissible by law and is not associated with any consumer brand or product.
This repository uses a community-driven model. This means that there are no dedicated developers working on new features or bug fixes or translations or documentation. Instead, it relies on the contributed efforts of those that choose to use it. This repository uses a community-driven model. This means that there are no dedicated developers working on new features or bug fixes or translations or documentation. Instead, it relies on the contributed efforts of those that choose to use it.