diff --git a/src/Access/Permissions.php b/src/Access/Permissions.php index 62044d952..1cc90c269 100644 --- a/src/Access/Permissions.php +++ b/src/Access/Permissions.php @@ -322,7 +322,7 @@ class Permissions $n = []; if ($p) { foreach ($p as $k => $v) { - if (intval($v)) { + if ((int)$v) { $n[] = $k; } } diff --git a/src/Lib/ActorId.php b/src/Lib/ActorId.php index 91f916081..ca5a90b1d 100644 --- a/src/Lib/ActorId.php +++ b/src/Lib/ActorId.php @@ -16,10 +16,10 @@ class ActorId public function __construct($id) { $this->id = $id; - if (str_contains($this->id, 'did:ap:key:')) { + if (str_contains($this->id, 'did:key:')) { $this->type = ActorId::ACTORID_TYPE_DID; - if (str_starts_with($this->id, 'http')) { - $this->id = substr($this->id, strpos($this->id, 'did:ap:key:')); + if (str_starts_with($this->id, 'http') || str_starts_with($this->id, 'ap://')) { + $this->id = substr($this->id, strpos($this->id, 'did:key:')); $this->id = substr($this->id, 0, strpos($this->id, '?') ? strpos($this->id, '?') : null); $this->id = substr($this->id, 0, strpos($this->id, '#') ? strpos($this->id, '#') : null); } diff --git a/src/Lib/Channel.php b/src/Lib/Channel.php index 4f287e7f7..d882c1600 100644 --- a/src/Lib/Channel.php +++ b/src/Lib/Channel.php @@ -2072,7 +2072,7 @@ class Channel else { $ed25519publicKey = (new Multibase())->publicKey($channel['channel_epubkey']); } - return 'did:ap:key:' . $ed25519publicKey; + return 'did:key:' . $ed25519publicKey; } public static function getDidActor($channel) diff --git a/src/Module/Apresolver.php b/src/Module/Apresolver.php index 3bc659573..9e12f003c 100644 --- a/src/Module/Apresolver.php +++ b/src/Module/Apresolver.php @@ -25,7 +25,7 @@ class Apresolver extends Controller $url .= argv($index); } // Extract the ed25519 key from the DID URL. - $key = str_replace('did:ap:key:', '', $url); + $key = str_replace('did:key:', '', $url); $key = rtrim($key, '/'); $index = strpos($key, '/'); $key = substr($key, 0, $index ?: null); @@ -38,7 +38,7 @@ class Apresolver extends Controller if (!($query && isset($query[0]['channel_id']))) { http_status_exit(404, 'Not found'); } - $mappedPath = $this->mapObject(str_replace('did:ap:key:' . $key, '', rtrim($url, '/')), $query[0]); + $mappedPath = $this->mapObject(str_replace('did:key:' . $key, '', rtrim($url, '/')), $query[0]); $localPath = ltrim($mappedPath, '/'); App::$cmd = $localPath; $controller = "\\Code\Module\\" . ucfirst(substr($localPath, 0, strpos($localPath, '/'))); diff --git a/tests/unit/Lib/ActorIdTest.php b/tests/unit/Lib/ActorIdTest.php index 71c189643..f8f3480cb 100644 --- a/tests/unit/Lib/ActorIdTest.php +++ b/tests/unit/Lib/ActorIdTest.php @@ -9,10 +9,10 @@ class ActorIdTest extends UnitTestCase public function testActorId() { - $this->assertEquals('did:ap:key:abc12345', (new ActorId('https://resolver.com/resolver/did:ap:key:abc12345?foo'))->getId()); - $this->assertEquals('did:ap:key:abc12345', (new ActorId('https://resolver.com/resolver/did:ap:key:abc12345#foo'))->getId()); + $this->assertEquals('did:key:abc12345', (new ActorId('https://resolver.com/resolver/did:key:abc12345?foo'))->getId()); + $this->assertEquals('did:key:abc12345', (new ActorId('https://resolver.com/resolver/did:key:abc12345#foo'))->getId()); $this->assertEquals('https://example.com/actor', (new ActorId('https://example.com/actor'))->getId()); - $this->assertEquals('did:ap:key:abc12345', (new ActorId('did:ap:key:abc12345'))->getId()); + $this->assertEquals('did:key:abc12345', (new ActorId('did:key:abc12345'))->getId()); }