Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Rename handleOrDid parameter to actor

+28 -28
+5 -5
src/AtpClientServiceProvider.php
··· 88 88 $this->app = $app; 89 89 } 90 90 91 - public function as(string $handleOrDid): AtpClient 91 + public function as(string $actor): AtpClient 92 92 { 93 93 return new AtpClient( 94 94 $this->app->make(SessionManager::class), 95 - $handleOrDid 95 + $actor 96 96 ); 97 97 } 98 98 99 - public function login(string $handleOrDid, string $password): AtpClient 99 + public function login(string $actor, string $password): AtpClient 100 100 { 101 101 $this->app->make(SessionManager::class) 102 - ->fromAppPassword($handleOrDid, $password); 102 + ->fromAppPassword($actor, $password); 103 103 104 - return $this->as($handleOrDid); 104 + return $this->as($actor); 105 105 } 106 106 107 107 public function oauth(): OAuthEngine
+3 -3
src/Auth/ScopeGate.php
··· 31 31 } 32 32 33 33 /** 34 - * Set the session context via handle or DID. 34 + * Set the session context via actor (handle or DID). 35 35 */ 36 - public function forUser(string $handleOrDid): self 36 + public function forUser(string $actor): self 37 37 { 38 38 $instance = new self($this->sessions, $this->checker); 39 - $instance->session = $this->sessions->session($handleOrDid); 39 + $instance->session = $this->sessions->session($actor); 40 40 41 41 return $instance; 42 42 }
+2 -2
src/Facades/Atp.php
··· 8 8 use SocialDept\AtpClient\Contracts\CredentialProvider; 9 9 10 10 /** 11 - * @method static AtpClient as(string $handleOrDid) 12 - * @method static AtpClient login(string $handleOrDid, string $password) 11 + * @method static AtpClient as(string $actor) 12 + * @method static AtpClient login(string $actor, string $password) 13 13 * @method static OAuthEngine oauth() 14 14 * @method static void setDefaultProvider(CredentialProvider $provider) 15 15 *
+1 -1
src/Facades/AtpScope.php
··· 9 9 10 10 /** 11 11 * @method static ScopeGate forSession(Session $session) 12 - * @method static ScopeGate forUser(string $handleOrDid) 12 + * @method static ScopeGate forUser(string $actor) 13 13 * @method static bool can(string|Scope $scope) 14 14 * @method static bool canAny(array $scopes) 15 15 * @method static bool canAll(array $scopes)
+17 -17
src/Session/SessionManager.php
··· 29 29 ) {} 30 30 31 31 /** 32 - * Resolve a handle or DID to a DID. 32 + * Resolve an actor (handle or DID) to a DID. 33 33 * 34 34 * @throws HandleResolutionException 35 35 */ 36 - protected function resolveToDid(string $handleOrDid): string 36 + protected function resolveToDid(string $actor): string 37 37 { 38 38 // If already a DID, return as-is 39 - if (Identity::isDid($handleOrDid)) { 40 - return $handleOrDid; 39 + if (Identity::isDid($actor)) { 40 + return $actor; 41 41 } 42 42 43 43 // Resolve handle to DID 44 - $did = Resolver::handleToDid($handleOrDid); 44 + $did = Resolver::handleToDid($actor); 45 45 46 46 if (! $did) { 47 - throw new HandleResolutionException($handleOrDid); 47 + throw new HandleResolutionException($actor); 48 48 } 49 49 50 50 return $did; 51 51 } 52 52 53 53 /** 54 - * Get or create session for handle or DID 54 + * Get or create session for an actor. 55 55 */ 56 - public function session(string $handleOrDid): Session 56 + public function session(string $actor): Session 57 57 { 58 - $did = $this->resolveToDid($handleOrDid); 58 + $did = $this->resolveToDid($actor); 59 59 60 60 if (! isset($this->sessions[$did])) { 61 61 $this->sessions[$did] = $this->createSession($did); ··· 65 65 } 66 66 67 67 /** 68 - * Ensure session is valid, refresh if needed 68 + * Ensure session is valid, refresh if needed. 69 69 */ 70 - public function ensureValid(string $handleOrDid): Session 70 + public function ensureValid(string $actor): Session 71 71 { 72 - $session = $this->session($handleOrDid); 72 + $session = $this->session($actor); 73 73 74 74 // Check if token needs refresh 75 75 if ($session->expiresIn() < $this->refreshThreshold) { ··· 80 80 } 81 81 82 82 /** 83 - * Create session from app password 83 + * Create session from app password. 84 84 */ 85 85 public function fromAppPassword( 86 - string $handleOrDid, 86 + string $actor, 87 87 string $password 88 88 ): Session { 89 - $did = $this->resolveToDid($handleOrDid); 89 + $did = $this->resolveToDid($actor); 90 90 $pdsEndpoint = Resolver::resolvePds($did); 91 91 92 92 $response = Http::post($pdsEndpoint.'/xrpc/com.atproto.server.createSession', [ 93 - 'identifier' => $handleOrDid, 93 + 'identifier' => $actor, 94 94 'password' => $password, 95 95 ]); 96 96 ··· 98 98 throw new AuthenticationException('Login failed'); 99 99 } 100 100 101 - $token = AccessToken::fromResponse($response->json(), $handleOrDid, $pdsEndpoint); 101 + $token = AccessToken::fromResponse($response->json(), $actor, $pdsEndpoint); 102 102 103 103 // Store credentials using DID as key 104 104 $this->credentials->storeCredentials($did, $token);