diff --git a/Code/Lib/Activity.php b/Code/Lib/Activity.php index c5d7e3e9d..3e4830024 100644 --- a/Code/Lib/Activity.php +++ b/Code/Lib/Activity.php @@ -2441,6 +2441,15 @@ class Activity } } } + $epubkey = ''; + if (isset($person_obj['assertionMethod']['publicKeyMultibase'])) { + if ($person_obj['id'] === $person_obj['assertionMethod']['controller']) { + $epubkey = $person_obj['assertionMethod']['publicKeyMultibase']; + if ($person_obj['assertionMethod']['type'] === 'Multikey') { + $epubkey = $person_obj['assertionMethod']['publicKeyMultibase']; + } + } + } $keywords = []; @@ -2490,6 +2499,7 @@ class Activity 'xchan_hash' => $url, 'xchan_guid' => $url, 'xchan_pubkey' => $pubkey, + 'xchan_epubkey' => $epubkey, 'xchan_addr' => $webfingerAddress, 'xchan_url' => $profile, 'xchan_name' => $name, @@ -2517,10 +2527,11 @@ class Activity // update existing record q( - "update xchan set xchan_updated = '%s', xchan_name = '%s', xchan_pubkey = '%s', xchan_network = '%s', xchan_name_date = '%s', xchan_hidden = %d, xchan_type = %d, xchan_censored = %d where xchan_hash = '%s'", + "update xchan set xchan_updated = '%s', xchan_name = '%s', xchan_pubkey = '%s', xchan_epubkey = '%s', xchan_network = '%s', xchan_name_date = '%s', xchan_hidden = %d, xchan_type = %d, xchan_censored = %d where xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($name), dbesc($pubkey), + dbesc($epubkey), dbesc('activitypub'), dbesc(datetime_convert()), intval($hidden), diff --git a/Code/Lib/Channel.php b/Code/Lib/Channel.php index 2525e2501..17631c4eb 100644 --- a/Code/Lib/Channel.php +++ b/Code/Lib/Channel.php @@ -473,6 +473,7 @@ class Channel 'xchan_guid' => $guid, 'xchan_guid_sig' => $sig, 'xchan_pubkey' => $key['pubkey'], + 'xchan_epubkey' => (new Multibase())->publicKey($ekey['pubkey']), 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'), 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}", diff --git a/Code/Lib/Libzot.php b/Code/Lib/Libzot.php index ccd32f33d..6a629b30d 100644 --- a/Code/Lib/Libzot.php +++ b/Code/Lib/Libzot.php @@ -864,6 +864,7 @@ class Libzot || ($r[0]['xchan_connurl'] !== $arr['primary_location']['connections_url']) || ($r[0]['xchan_addr'] !== $arr['primary_location']['address']) || ($r[0]['xchan_follow'] !== $arr['primary_location']['follow_url']) + || ($r[0]['xchan_epubkey'] !== $arr['ed25519_key']) || ($r[0]['xchan_connpage'] !== $arr['connect_url']) || ($r[0]['xchan_url'] !== $arr['primary_location']['url']) || ($r[0]['xchan_network'] !== $network) @@ -917,6 +918,7 @@ class Libzot 'xchan_guid' => $arr['id'], 'xchan_guid_sig' => $arr['id_sig'], 'xchan_pubkey' => $arr['public_key'], + 'xchan_epubkey' => $arr['ed25519_key'], 'xchan_photo_mimetype' => $arr['photo']['type'], 'xchan_photo_l' => $arr['photo']['url'], 'xchan_addr' => escape_tags($arr['primary_location']['address']), @@ -3015,6 +3017,7 @@ class Libzot $ret['primary_location'] = $primary->toArray(); $ret['public_key'] = $e['xchan_pubkey']; + $ret['ed25519_key'] = $e['xchan_epubkey']; $ret['signing_algorithm'] = 'rsa-sha256'; $ret['username'] = $e['channel_address']; $ret['name'] = $e['xchan_name']; diff --git a/Code/Update/_1275.php b/Code/Update/_1275.php new file mode 100644 index 000000000..42757899b --- /dev/null +++ b/Code/Update/_1275.php @@ -0,0 +1,39 @@ +publicKey($channel['channel_epubkey']); + q("update xchan set xchan_epubkey = '%s' where xchan_url = '%s'", + dbesc($epubkey), + dbesc(Channel::url($channel)) + ); + } + } + return UPDATE_SUCCESS; + } + + public function verify() + { + return true; + } +} \ No newline at end of file diff --git a/boot.php b/boot.php index f7bd2d000..c55fbde4a 100755 --- a/boot.php +++ b/boot.php @@ -26,7 +26,7 @@ use Code\Lib\Url; */ const REPOSITORY_ID = 'streams'; -const DB_UPDATE_VERSION = 1274; +const DB_UPDATE_VERSION = 1276; const PROJECT_BASE = __DIR__; const ACTIVITYPUB_ENABLED = true; const NOMAD_PROTOCOL_VERSION = '12.0'; diff --git a/include/system_unavailable.php b/include/system_unavailable.php index 935344549..3b886e8f5 100644 --- a/include/system_unavailable.php +++ b/include/system_unavailable.php @@ -2,11 +2,11 @@ require_once("include/network.php"); -if (! function_exists('system_down')) { - function system_down(): void - { - http_status(503, 'Service Unavailable', false); - echo <<< EOT + +function system_down(): void +{ + http_status(503, 'Service Unavailable', false); + echo <<< EOT System Unavailable @@ -15,6 +15,6 @@ Apologies but this site is unavailable at the moment. Please try again later. EOT; - } + } \ No newline at end of file diff --git a/include/xchan.php b/include/xchan.php index c63f01009..436c5ad3d 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -12,6 +12,7 @@ function xchan_store_lowlevel($arr) 'xchan_guid' => ((array_key_exists('xchan_guid', $arr)) ? $arr['xchan_guid'] : ''), 'xchan_guid_sig' => ((array_key_exists('xchan_guid_sig', $arr)) ? $arr['xchan_guid_sig'] : ''), 'xchan_pubkey' => ((array_key_exists('xchan_pubkey', $arr)) ? $arr['xchan_pubkey'] : ''), + 'xchan_epubkey' => ((array_key_exists('xchan_epubkey', $arr)) ? $arr['xchan_epubkey'] : ''), 'xchan_photo_mimetype' => ((array_key_exists('xchan_photo_mimetype', $arr)) ? $arr['xchan_photo_mimetype'] : ''), 'xchan_photo_l' => ((array_key_exists('xchan_photo_l', $arr)) ? $arr['xchan_photo_l'] : ''), 'xchan_photo_m' => ((array_key_exists('xchan_photo_m', $arr)) ? $arr['xchan_photo_m'] : ''), diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index 9b969268d..aaa7cafe4 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -1165,6 +1165,7 @@ CREATE TABLE IF NOT EXISTS `xchan` ( `xchan_guid` varchar(255) NOT NULL DEFAULT '', `xchan_guid_sig` text NOT NULL, `xchan_pubkey` text NOT NULL, + `xchan_epubkey` text NOT NULL, `xchan_photo_mimetype` varchar(255) NOT NULL DEFAULT 'image/jpeg', `xchan_photo_l` varchar(255) NOT NULL DEFAULT '', `xchan_photo_m` varchar(255) NOT NULL DEFAULT '', diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index d3994de59..36c41996a 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -1234,6 +1234,7 @@ CREATE TABLE "xchan" ( "xchan_guid" text NOT NULL DEFAULT '', "xchan_guid_sig" text NOT NULL DEFAULT '', "xchan_pubkey" text NOT NULL DEFAULT '', + "xchan_epubkey" text NOT NULL DEFAULT '', "xchan_photo_mimetype" text NOT NULL DEFAULT 'image/jpeg', "xchan_photo_l" text NOT NULL DEFAULT '', "xchan_photo_m" text NOT NULL DEFAULT '',