diff options
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 12 | ||||
-rw-r--r-- | Zotlabs/Lib/LDSignatures.php | 7 | ||||
-rw-r--r-- | Zotlabs/Lib/NativeWikiPage.php | 20 |
3 files changed, 30 insertions, 9 deletions
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index 686f4a140..2846ea476 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -13,7 +13,9 @@ class ActivityStreams { public $tgt = null; public $origin = null; public $owner = null; - + public $signer = null; + public $ldsig = null; + public $sigok = false; public $recips = null; function __construct($string) { @@ -32,6 +34,14 @@ class ActivityStreams { $this->origin = $this->get_compound_property('origin'); $this->recips = $this->collect_recips(); + $this->ldsig = $this->get_compound_property('signature'); + if($this->ldsig) { + $this->signer = $this->get_compound_property('creator',$this->ldsig); + if($this->signer && $this->signer['publicKey'] && $this->signer['publicKey']['publicKeyPem']) { + $this->sigok = \Zotlabs\Lib\LDSignatures::verify($this->data,$this->signer['publicKey']['publicKeyPem']); + } + } + if(($this->type === 'Note') && (! $this->obj)) { $this->obj = $this->data; $this->type = 'Create'; diff --git a/Zotlabs/Lib/LDSignatures.php b/Zotlabs/Lib/LDSignatures.php index 88dfe80c0..fa2758044 100644 --- a/Zotlabs/Lib/LDSignatures.php +++ b/Zotlabs/Lib/LDSignatures.php @@ -16,11 +16,13 @@ class LDSignatures { } static function dopplesign(&$data,$channel) { - $data['magicEnv'] = self::salmon_sign($data,$channel); + // remove for the time being - performance issues + // $data['magicEnv'] = self::salmon_sign($data,$channel); return self::sign($data,$channel); } static function sign($data,$channel) { + $options = [ 'type' => 'RsaSignature2017', 'nonce' => random_string(64), @@ -46,7 +48,7 @@ class LDSignatures { if($data) { foreach($data as $k => $v) { if(! in_array($k,[ 'signature' ])) { - $newopts[$k] = $v; + $newdata[$k] = $v; } } } @@ -68,6 +70,7 @@ class LDSignatures { } static function hash($obj) { + return hash('sha256',self::normalise($obj)); } diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php index 78b54ebda..ffd5aec31 100644 --- a/Zotlabs/Lib/NativeWikiPage.php +++ b/Zotlabs/Lib/NativeWikiPage.php @@ -55,7 +55,12 @@ class NativeWikiPage { } - static public function create_page($channel_id, $observer_hash, $name, $resource_id) { + static public function create_page($channel_id, $observer_hash, $name, $resource_id, $mimetype = 'text/bbcode') { + + logger('mimetype: ' . $mimetype); + + if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html' ])) + $mimetype = 'text/markdown'; $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id); @@ -68,6 +73,7 @@ class NativeWikiPage { $arr = []; $arr['uid'] = $channel_id; $arr['author_xchan'] = $observer_hash; + $arr['mimetype'] = $mimetype; $arr['resource_type'] = 'nwikipage'; $arr['resource_id'] = $resource_id; $arr['allow_cid'] = $w['wiki']['allow_cid']; @@ -167,10 +173,11 @@ class NativeWikiPage { $content = $item['body']; return [ - 'content' => $content, - 'mimeType' => $w['mimeType'], - 'message' => '', - 'success' => true + 'content' => $content, + 'mimeType' => $w['mimeType'], + 'pageMimeType' => $item['mimetype'], + 'message' => '', + 'success' => true ]; } @@ -333,7 +340,6 @@ class NativeWikiPage { return array('message' => t('Error reading wiki'), 'success' => false); } - $mimetype = $w['mimeType']; // fetch the most recently saved revision. @@ -342,6 +348,8 @@ class NativeWikiPage { return array('message' => t('Page not found'), 'success' => false); } + $mimetype = $item['mimetype']; + // change just the fields we need to change to create a revision; unset($item['id']); |