mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:35:12 +00:00
partial update to new ap:// DID scheme
This commit is contained in:
parent
f5fbe5a80a
commit
1f895f6f76
5 changed files with 10 additions and 10 deletions
|
@ -322,7 +322,7 @@ class Permissions
|
|||
$n = [];
|
||||
if ($p) {
|
||||
foreach ($p as $k => $v) {
|
||||
if (intval($v)) {
|
||||
if ((int)$v) {
|
||||
$n[] = $k;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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, '/')));
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue