Skip to content

Commit

Permalink
Create identity.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kawax committed Dec 4, 2024
1 parent f6b769e commit 0595e7e
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions docs/identity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Resolve Identity
====

- https://docs.bsky.app/docs/advanced-guides/resolving-identities
- https://atproto.com/ja/guides/identity

## Handle to DID

Using API.

```php
use Revolution\Bluesky\Facades\Bluesky;

$did = Bluesky::resolveHandle('***.bsky.social')->json('did');
```

Check DNS TXT or `/.well-known/atproto-did`.

```php
use Revolution\Bluesky\Facades\Bluesky;

$did = Bluesky::identity()->resolveHandle('alice.test');
```

They are similar but different.

## DID to DID Document

`resolveDID` returns didDoc.

https://plc.directory/did:plc:ewvi7nxzyoun6zhxrhs64oiz

```php
use Revolution\Bluesky\Facades\Bluesky;

$didDoc = Bluesky::identity()->resolveDID('did:plc:*** or did:web:***')->json();
```

## DID(Document) to Handle

`alsoKnownAs` in didDoc is handle.

```php
use Revolution\Bluesky\Facades\Bluesky;
use Revolution\Bluesky\Support\DidDocument;

$didDoc = DidDocument::make(Bluesky::identity()->resolveDID('did:plc:*** or did:web:***')->json());
$handle = $didDoc->handle();
```

## resolveIdentity

`resolveIdentity` which combines `resolveHandle` and `resolveDID`, can resolve from either did or handle and returns didDoc.

```php
use Revolution\Bluesky\Facades\Bluesky;
use Revolution\Bluesky\Support\DidDocument;

$didDoc = DidDocument::make(Bluesky::identity()->resolveIdentity('did or handle')->json());
$didDoc->id();
$didDoc->handle();
```

## Public profile

Public profile can be resolved from either did or handle and the response will include both did and handle.

```php
use Revolution\Bluesky\Facades\Bluesky;

$profile = Bluesky::getProfile('did or handle');
$profile->json('did');
$profile->json('handle');
```

## PDS url / serviceEndpoint

Although it is unlikely to be used directly, the `serviceEndpoint` in didDoc is the PDS URL.

`https://***.***.host.bsky.network`

```php
use Revolution\Bluesky\Facades\Bluesky;
use Revolution\Bluesky\Support\DidDocument;

$didDoc = DidDocument::make(Bluesky::identity()->resolveIdentity('did or handle')->json());
$didDoc->pdsUrl();
```

## Authorization Server / Service / Issuer url

This can be solved through PDS.

If you signed up with Bluesky, this should be `https://bsky.social`

```php
use Revolution\Bluesky\Facades\Bluesky;
use Revolution\Bluesky\Support\DidDocument;

$didDoc = DidDocument::make(Bluesky::identity()->resolveIdentity('did or handle')->json());

$pds = Bluesky::pds()->getProtectedResource($didDoc->pdsUrl());
$pds->authServer();
```

0 comments on commit 0595e7e

Please sign in to comment.