Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

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

Consolidate and rename auth events to Session* naming convention

+37 -42
+2 -2
src/Auth/OAuthEngine.php
··· 6 6 use SocialDept\AtpClient\Data\AccessToken; 7 7 use SocialDept\AtpClient\Data\AuthorizationRequest; 8 8 use SocialDept\AtpClient\Data\DPoPKey; 9 - use SocialDept\AtpClient\Events\OAuthUserAuthenticated; 9 + use SocialDept\AtpClient\Events\SessionAuthenticated; 10 10 use SocialDept\AtpClient\Contracts\KeyStore; 11 11 use SocialDept\AtpClient\Exceptions\AuthenticationException; 12 12 use SocialDept\AtpClient\Http\DPoPClient; ··· 111 111 $sessionId = 'session_'.hash('sha256', $token->did); 112 112 $this->keyStore->store($sessionId, $request->dpopKey); 113 113 114 - event(new OAuthUserAuthenticated($token)); 114 + event(new SessionAuthenticated($token)); 115 115 116 116 return $token; 117 117 }
-16
src/Events/LegacyUserAuthenticated.php
··· 1 - <?php 2 - 3 - namespace SocialDept\AtpClient\Events; 4 - 5 - use Illuminate\Foundation\Events\Dispatchable; 6 - use Illuminate\Queue\SerializesModels; 7 - use SocialDept\AtpClient\Data\AccessToken; 8 - 9 - class LegacyUserAuthenticated 10 - { 11 - use Dispatchable, SerializesModels; 12 - 13 - public function __construct( 14 - public readonly AccessToken $token, 15 - ) {} 16 - }
-16
src/Events/OAuthUserAuthenticated.php
··· 1 - <?php 2 - 3 - namespace SocialDept\AtpClient\Events; 4 - 5 - use Illuminate\Foundation\Events\Dispatchable; 6 - use Illuminate\Queue\SerializesModels; 7 - use SocialDept\AtpClient\Data\AccessToken; 8 - 9 - class OAuthUserAuthenticated 10 - { 11 - use Dispatchable, SerializesModels; 12 - 13 - public function __construct( 14 - public readonly AccessToken $token, 15 - ) {} 16 - }
+27
src/Events/SessionAuthenticated.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Events; 4 + 5 + use Illuminate\Foundation\Events\Dispatchable; 6 + use Illuminate\Queue\SerializesModels; 7 + use SocialDept\AtpClient\Data\AccessToken; 8 + use SocialDept\AtpClient\Enums\AuthType; 9 + 10 + class SessionAuthenticated 11 + { 12 + use Dispatchable, SerializesModels; 13 + 14 + public function __construct( 15 + public readonly AccessToken $token, 16 + ) {} 17 + 18 + public function isOAuth(): bool 19 + { 20 + return $this->token->authType === AuthType::OAuth; 21 + } 22 + 23 + public function isLegacy(): bool 24 + { 25 + return $this->token->authType === AuthType::Legacy; 26 + } 27 + }
+1 -1
src/Events/TokenRefreshed.php src/Events/SessionUpdated.php
··· 7 7 use SocialDept\AtpClient\Data\AccessToken; 8 8 use SocialDept\AtpClient\Session\Session; 9 9 10 - class TokenRefreshed 10 + class SessionUpdated 11 11 { 12 12 use Dispatchable, SerializesModels; 13 13
+1 -1
src/Events/TokenRefreshing.php src/Events/SessionRefreshing.php
··· 6 6 use Illuminate\Queue\SerializesModels; 7 7 use SocialDept\AtpClient\Session\Session; 8 8 9 - class TokenRefreshing 9 + class SessionRefreshing 10 10 { 11 11 use Dispatchable, SerializesModels; 12 12
+6 -6
src/Session/SessionManager.php
··· 8 8 use SocialDept\AtpClient\Contracts\CredentialProvider; 9 9 use SocialDept\AtpClient\Contracts\KeyStore; 10 10 use SocialDept\AtpClient\Data\AccessToken; 11 - use SocialDept\AtpClient\Events\LegacyUserAuthenticated; 12 - use SocialDept\AtpClient\Events\TokenRefreshed; 13 - use SocialDept\AtpClient\Events\TokenRefreshing; 11 + use SocialDept\AtpClient\Events\SessionAuthenticated; 12 + use SocialDept\AtpClient\Events\SessionRefreshing; 13 + use SocialDept\AtpClient\Events\SessionUpdated; 14 14 use SocialDept\AtpClient\Exceptions\AuthenticationException; 15 15 use SocialDept\AtpClient\Exceptions\HandleResolutionException; 16 16 use SocialDept\AtpClient\Exceptions\SessionExpiredException; ··· 104 104 // Store credentials using DID as key 105 105 $this->credentials->storeCredentials($did, $token); 106 106 107 - event(new LegacyUserAuthenticated($token)); 107 + event(new SessionAuthenticated($token)); 108 108 109 109 return $this->createSession($did); 110 110 } ··· 142 142 $did = $session->did(); 143 143 144 144 // Fire event before refresh (allows developers to invalidate old token) 145 - event(new TokenRefreshing($session)); 145 + event(new SessionRefreshing($session)); 146 146 147 147 $newToken = $this->refresher->refresh( 148 148 refreshToken: $session->refreshToken(), ··· 156 156 $this->credentials->updateCredentials($did, $newToken); 157 157 158 158 // Fire event after successful refresh 159 - event(new TokenRefreshed($session, $newToken)); 159 + event(new SessionUpdated($session, $newToken)); 160 160 161 161 // Update session 162 162 $newCreds = $this->credentials->getCredentials($did);