diff options
author | Mario <mario@mariovavti.com> | 2024-01-10 13:33:57 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-01-10 13:33:57 +0000 |
commit | 58593d7da6a893e681b7c64fdf21a02c93dfa0d0 (patch) | |
tree | 9da45b10745d41f4fe66afff9c27b87589ce5e91 /Zotlabs/Lib/Activity.php | |
parent | 4aa29db7aac6c389a1908a53bce2ec36d7f94ee1 (diff) | |
download | volse-hubzilla-58593d7da6a893e681b7c64fdf21a02c93dfa0d0.tar.gz volse-hubzilla-58593d7da6a893e681b7c64fdf21a02c93dfa0d0.tar.bz2 volse-hubzilla-58593d7da6a893e681b7c64fdf21a02c93dfa0d0.zip |
prepare outbound fep-8b32 (object integrity) but do not enable yet since the additional context seems to break ldsig for some reason, introduce Activity::build_packet() and Activity::ap_context() to reduce code duplication, implement fep-2c59 (webfinger) and some cleanup
Diffstat (limited to 'Zotlabs/Lib/Activity.php')
-rw-r--r-- | Zotlabs/Lib/Activity.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 0dfa15aea..766b4ed91 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -4211,4 +4211,80 @@ class Activity { } + public static function ap_context($contextType = null): array { + return ['@context' => [ + ACTIVITYSTREAMS_JSONLD_REV, + 'https://w3id.org/security/v1', + // 'https://www.w3.org/ns/did/v1', + // 'https://w3id.org/security/multikey/v1', + // 'https://w3id.org/security/data-integrity/v1', + 'https://purl.archive.org/socialweb/webfinger', + self::ap_schema($contextType) + ]]; + } + + public static function ap_schema($contextType = null): array { + // $contextType is reserved for future use so that the caller can specify + // a limited subset of the entire schema definition for particular activities. + + return [ + 'zot' => z_root() . '/apschema#', + 'schema' => 'http://schema.org#', + 'ostatus' => 'http://ostatus.org#', + 'diaspora' => 'https://diasporafoundation.org/ns/', + + 'commentPolicy' => 'zot:commentPolicy', + 'locationAddress' => 'zot:locationAddress', + 'locationPrimary' => 'zot:locationPrimary', + 'locationDeleted' => 'zot:locationDeleted', + 'nomadicLocation' => 'zot:nomadicLocation', + 'nomadicHubs' => 'zot:nomadicHubs', + 'emojiReaction' => 'zot:emojiReaction', + 'expires' => 'zot:expires', + 'directMessage' => 'zot:directMessage', + 'Bookmark' => 'zot:Bookmark', + 'Category' => 'zot:Category', + + 'PropertyValue' => 'schema:PropertyValue', + 'value' => 'schema:value', + + 'conversation' => 'ostatus:conversation', + + 'guid' => 'diaspora:guid', + + 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', + 'Hashtag' => 'as:Hashtag' + + ]; + + } + + /** + * @brief Builds the activity packet and signs it if $channel is provided. + * + * @param array $obj + * @param array $channel (optional) default [] + * @param bool $json_encode (optional) default true + * @return string|array + */ + + public static function build_packet(array $obj, array $channel = [], bool $json_encode = true): string|array { + $arr = array_merge(Activity::ap_context(), $obj); + + if ($channel) { + // $proof = (new JcsEddsa2022)->sign($arr, $channel); + // $arr['proof'] = $proof; + + $signature = LDSignatures::sign($arr, $channel); + $arr['signature'] = $signature; + } + + if ($json_encode) { + return json_encode($arr, JSON_UNESCAPED_SLASHES); + } + + return $arr; + } + + } |