From a03e422547e3701dc9c09049b1d4f31aa22186ff Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Wed, 20 Mar 2024 21:37:02 +1100 Subject: [PATCH] report test warnings --- phpunit.xml | 2 +- src/Lib/Channel.php | 7 +++++++ src/Lib/JcsEddsa2022.php | 4 +--- tests/phpunit.xml | 2 +- tests/unit/Lib/JcsEddsa2022Test.php | 2 ++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 42150623e..0b2c1fb42 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,5 @@ - + tests diff --git a/src/Lib/Channel.php b/src/Lib/Channel.php index 2804f01ae..dcc8572c1 100644 --- a/src/Lib/Channel.php +++ b/src/Lib/Channel.php @@ -2075,6 +2075,13 @@ class Channel return self::getDid($channel) . '/actor'; } + public static function getVerifier($channel) + { + $pubkey = (new Multibase())->publicKey($channel['channel_epubkey']); + $nomadic = PConfig::Get($channel['channel_id'], 'system', 'nomadicAP'); + return (($nomadic) ? Channel::getDidResolver($channel) . '/actor' : Channel::url($channel) . '#' . $pubkey); + } + public static function getDidResolver($channel) { return z_root() . '/.well-known/apresolver/' . self::getDid($channel); diff --git a/src/Lib/JcsEddsa2022.php b/src/Lib/JcsEddsa2022.php index b75af0a43..e637b3308 100644 --- a/src/Lib/JcsEddsa2022.php +++ b/src/Lib/JcsEddsa2022.php @@ -16,14 +16,12 @@ class JcsEddsa2022 public function sign($data, $channel): array { unset($data['proof']); // Discard any pre-existing signature if it exists - $nomadic = (int) PConfig::Get($channel['channel_id'], 'system', 'nomadicAP'); - $pubkey = (new Multibase())->publicKey($channel['channel_epubkey']); $options = [ 'type' => 'DataIntegrityProof', 'cryptosuite' => 'eddsa-jcs-2022', 'created' => Time::convert(format: ISO8601), - 'verificationMethod' => (($nomadic) ? Channel::getDidResolver($channel) . '/actor' : Channel::url($channel) . '#' . $pubkey), + 'verificationMethod' => Channel::getVerifier($channel), 'proofPurpose' => 'assertionMethod', ]; diff --git a/tests/phpunit.xml b/tests/phpunit.xml index 863fa1bb8..bf0d78027 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -1,5 +1,5 @@ - + ../tests diff --git a/tests/unit/Lib/JcsEddsa2022Test.php b/tests/unit/Lib/JcsEddsa2022Test.php index 744f539d8..578d6cf0f 100644 --- a/tests/unit/Lib/JcsEddsa2022Test.php +++ b/tests/unit/Lib/JcsEddsa2022Test.php @@ -4,6 +4,7 @@ namespace Code\Tests\Unit\Lib; use Code\Lib\Activity; use Code\Lib\JcsEddsa2022; +use Code\Lib\PConfig; use Code\Tests\Unit\UnitTestCase; class JcsEddsa2022Test extends UnitTestCase @@ -51,6 +52,7 @@ class JcsEddsa2022Test extends UnitTestCase { $publicKey = 'z6MkfpucGTDbMZADwM6vEa8pS3s8Z9xqSEn6HihijZ4fVs9d'; $channel = [ + 'channel_id' => 1, 'channel_url' => 'https://example.com/channel/klingon', 'channel_epubkey' => 'FGdbYgr526Swuyya3e8epCBdHahlWNg9I0sBhMKCzpw', 'channel_eprvkey' => 'StLRo8xb7VJ5XdR10OUYQM/uooP7D7fMlgvQFa1wrZIUZ1tiCvnbpLC7LJrd7x6kIF0dqGVY2D0jSwGEwoLOnA',