Resolve AT Protocol DIDs, handles, and schemas with intelligent caching for Laravel

Rename package from `Beacon` to `Resovler`

+67 -67
README.md
··· 1 - [![Beacon Header](./header.png)](https://github.com/socialdept/atp-signals) 1 + [![Resolver Header](./header.png)](https://github.com/socialdept/atp-signals) 2 2 3 3 <h3 align="center"> 4 4 Resolve AT Protocol identities in your Laravel application. ··· 6 6 7 7 <p align="center"> 8 8 <br> 9 - <a href="https://packagist.org/packages/socialdept/atp-beacon" title="Latest Version on Packagist"><img src="https://img.shields.io/packagist/v/socialdept/atp-beacon.svg?style=flat-square"></a> 10 - <a href="https://packagist.org/packages/socialdept/atp-beacon" title="Total Downloads"><img src="https://img.shields.io/packagist/dt/socialdept/atp-beacon.svg?style=flat-square"></a> 11 - <a href="https://github.com/socialdept/atp-beacon/actions/workflows/tests.yml" title="GitHub Tests Action Status"><img src="https://img.shields.io/github/actions/workflow/status/socialdept/atp-beacon/tests.yml?branch=main&label=tests&style=flat-square"></a> 12 - <a href="LICENSE" title="Software License"><img src="https://img.shields.io/github/license/socialdept/atp-beacon?style=flat-square"></a> 9 + <a href="https://packagist.org/packages/socialdept/atp-resolver" title="Latest Version on Packagist"><img src="https://img.shields.io/packagist/v/socialdept/atp-resolver.svg?style=flat-square"></a> 10 + <a href="https://packagist.org/packages/socialdept/atp-resolver" title="Total Downloads"><img src="https://img.shields.io/packagist/dt/socialdept/atp-resolver.svg?style=flat-square"></a> 11 + <a href="https://github.com/socialdept/atp-resolver/actions/workflows/tests.yml" title="GitHub Tests Action Status"><img src="https://img.shields.io/github/actions/workflow/status/socialdept/atp-resolver/tests.yml?branch=main&label=tests&style=flat-square"></a> 12 + <a href="LICENSE" title="Software License"><img src="https://img.shields.io/github/license/socialdept/atp-resolver?style=flat-square"></a> 13 13 </p> 14 14 15 15 --- 16 16 17 - ## What is Beacon? 17 + ## What is Resolver? 18 18 19 - **Beacon** is a Laravel package that resolves AT Protocol identities. Convert DIDs to handles, find PDS endpoints, and resolve DID documents with automatic caching and fallback support for both `did:plc` and `did:web` methods. 19 + **Resolver** is a Laravel package that resolves AT Protocol identities. Convert DIDs to handles, find PDS endpoints, and resolve DID documents with automatic caching and fallback support for both `did:plc` and `did:web` methods. 20 20 21 21 Think of it as a Swiss Army knife for AT Protocol identity resolution. 22 22 23 - ## Why use Beacon? 23 + ## Why use Resolver? 24 24 25 25 - **Simple API** - Resolve DIDs and handles with one method call 26 26 - **Automatic caching** - Smart caching with configurable TTLs ··· 32 32 ## Quick Example 33 33 34 34 ```php 35 - use SocialDept\Beacon\Facades\Beacon; 35 + use SocialDept\Resolver\Facades\Resolver; 36 36 37 37 // Resolve a DID to its document 38 - $document = Beacon::resolveDid('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 38 + $document = Resolver::resolveDid('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 39 39 $handle = $document->getHandle(); // "user.bsky.social" 40 40 $pds = $document->getPdsEndpoint(); // "https://bsky.social" 41 41 42 42 // Convert a handle to its DID 43 - $did = Beacon::handleToDid('user.bsky.social'); 43 + $did = Resolver::handleToDid('user.bsky.social'); 44 44 // "did:plc:ewvi7nxzyoun6zhxrhs64oiz" 45 45 46 46 // Resolve any identity (DID or handle) to a document 47 - $document = Beacon::resolveIdentity('alice.bsky.social'); 47 + $document = Resolver::resolveIdentity('alice.bsky.social'); 48 48 49 49 // Find someone's PDS endpoint 50 - $pds = Beacon::resolvePds('alice.bsky.social'); 50 + $pds = Resolver::resolvePds('alice.bsky.social'); 51 51 // "https://bsky.social" 52 52 ``` 53 53 54 54 ## Installation 55 55 56 56 ```bash 57 - composer require socialdept/atp-beacon 57 + composer require socialdept/atp-resolver 58 58 ``` 59 59 60 - Beacon will auto-register with Laravel. Optionally publish the config: 60 + Resolver will auto-register with Laravel. Optionally publish the config: 61 61 62 62 ```bash 63 - php artisan vendor:publish --tag=beacon-config 63 + php artisan vendor:publish --tag=resolver-config 64 64 ``` 65 65 66 66 ## Basic Usage 67 67 68 68 ### Resolving DIDs 69 69 70 - Beacon supports both `did:plc` and `did:web` methods: 70 + Resolver supports both `did:plc` and `did:web` methods: 71 71 72 72 ```php 73 - use SocialDept\Beacon\Facades\Beacon; 73 + use SocialDept\Resolver\Facades\Resolver; 74 74 75 75 // PLC directory resolution 76 - $document = Beacon::resolveDid('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 76 + $document = Resolver::resolveDid('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 77 77 78 78 // Web DID resolution 79 - $document = Beacon::resolveDid('did:web:example.com'); 79 + $document = Resolver::resolveDid('did:web:example.com'); 80 80 81 81 // Access document data 82 82 $handle = $document->getHandle(); ··· 90 90 91 91 ```php 92 92 // Convert handle to DID string 93 - $did = Beacon::handleToDid('alice.bsky.social'); 93 + $did = Resolver::handleToDid('alice.bsky.social'); 94 94 // "did:plc:ewvi7nxzyoun6zhxrhs64oiz" 95 95 96 96 // Resolve handle to full DID document 97 - $document = Beacon::resolveHandle('alice.bsky.social'); 97 + $document = Resolver::resolveHandle('alice.bsky.social'); 98 98 $handle = $document->getHandle(); 99 99 $pds = $document->getPdsEndpoint(); 100 100 ``` ··· 105 105 106 106 ```php 107 107 // Works with DIDs 108 - $document = Beacon::resolveIdentity('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 108 + $document = Resolver::resolveIdentity('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 109 109 110 110 // Works with handles 111 - $document = Beacon::resolveIdentity('alice.bsky.social'); 111 + $document = Resolver::resolveIdentity('alice.bsky.social'); 112 112 113 113 // Perfect for user input where type is unknown 114 114 $actor = $request->input('actor'); // Could be DID or handle 115 - $document = Beacon::resolveIdentity($actor); 115 + $document = Resolver::resolveIdentity($actor); 116 116 ``` 117 117 118 118 ### Finding PDS Endpoints ··· 121 121 122 122 ```php 123 123 // From a DID 124 - $pds = Beacon::resolvePds('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 124 + $pds = Resolver::resolvePds('did:plc:ewvi7nxzyoun6zhxrhs64oiz'); 125 125 126 126 // From a handle 127 - $pds = Beacon::resolvePds('alice.bsky.social'); 127 + $pds = Resolver::resolvePds('alice.bsky.social'); 128 128 129 129 // Returns: "https://bsky.social" or user's custom PDS 130 130 ``` ··· 137 137 138 138 ```php 139 139 // Clear specific DID cache 140 - Beacon::clearDidCache('did:plc:abc123'); 140 + Resolver::clearDidCache('did:plc:abc123'); 141 141 142 142 // Clear specific handle cache 143 - Beacon::clearHandleCache('alice.bsky.social'); 143 + Resolver::clearHandleCache('alice.bsky.social'); 144 144 145 145 // Clear specific PDS cache 146 - Beacon::clearPdsCache('alice.bsky.social'); 146 + Resolver::clearPdsCache('alice.bsky.social'); 147 147 148 148 // Clear all cached data 149 - Beacon::clearCache(); 149 + Resolver::clearCache(); 150 150 ``` 151 151 152 152 ### Disable Caching ··· 154 154 Pass `false` as the second parameter to bypass cache: 155 155 156 156 ```php 157 - $document = Beacon::resolveDid('did:plc:abc123', useCache: false); 158 - $did = Beacon::handleToDid('alice.bsky.social', useCache: false); 159 - $document = Beacon::resolveIdentity('alice.bsky.social', useCache: false); 160 - $pds = Beacon::resolvePds('alice.bsky.social', useCache: false); 157 + $document = Resolver::resolveDid('did:plc:abc123', useCache: false); 158 + $did = Resolver::handleToDid('alice.bsky.social', useCache: false); 159 + $document = Resolver::resolveIdentity('alice.bsky.social', useCache: false); 160 + $pds = Resolver::resolvePds('alice.bsky.social', useCache: false); 161 161 ``` 162 162 163 163 ### Identity Validation ··· 165 165 Beacon includes static helper methods to validate DIDs and handles: 166 166 167 167 ```php 168 - use SocialDept\Beacon\Support\Identity; 168 + use SocialDept\Resolver\Support\Identity; 169 169 170 170 // Validate handles 171 171 Identity::isHandle('alice.bsky.social'); // true ··· 189 189 190 190 ## Configuration 191 191 192 - Beacon works great with zero configuration, but you can customize behavior in `config/beacon.php`: 192 + Beacon works great with zero configuration, but you can customize behavior in `config/resolver.php`: 193 193 194 194 ```php 195 195 return [ 196 196 // PLC directory for did:plc resolution 197 - 'plc_directory' => env('BEACON_PLC_DIRECTORY', 'https://plc.directory'), 197 + 'plc_directory' => env('RESOLVER_PLC_DIRECTORY', 'https://plc.directory'), 198 198 199 199 // Default PDS endpoint for handle resolution 200 - 'pds_endpoint' => env('BEACON_PDS_ENDPOINT', 'https://bsky.social'), 200 + 'pds_endpoint' => env('RESOLVER_PDS_ENDPOINT', 'https://bsky.social'), 201 201 202 202 // HTTP request timeout 203 - 'timeout' => env('BEACON_TIMEOUT', 10), 203 + 'timeout' => env('RESOLVER_TIMEOUT', 10), 204 204 205 205 // Cache configuration 206 206 'cache' => [ 207 - 'enabled' => env('BEACON_CACHE_ENABLED', true), 207 + 'enabled' => env('RESOLVER_CACHE_ENABLED', true), 208 208 209 209 // Cache TTL for DID documents (1 hour) 210 - 'did_ttl' => env('BEACON_CACHE_DID_TTL', 3600), 210 + 'did_ttl' => env('RESOLVER_CACHE_DID_TTL', 3600), 211 211 212 212 // Cache TTL for handle resolutions (1 hour) 213 - 'handle_ttl' => env('BEACON_CACHE_HANDLE_TTL', 3600), 213 + 'handle_ttl' => env('RESOLVER_CACHE_HANDLE_TTL', 3600), 214 214 215 215 // Cache TTL for PDS endpoints (1 hour) 216 - 'pds_ttl' => env('BEACON_CACHE_PDS_TTL', 3600), 216 + 'pds_ttl' => env('RESOLVER_CACHE_PDS_TTL', 3600), 217 217 ], 218 218 ]; 219 219 ``` ··· 224 224 225 225 ```php 226 226 // DID Resolution 227 - Beacon::resolveDid(string $did, bool $useCache = true): DidDocument 227 + Resolver::resolveDid(string $did, bool $useCache = true): DidDocument 228 228 229 229 // Handle Resolution 230 - Beacon::handleToDid(string $handle, bool $useCache = true): string 231 - Beacon::resolveHandle(string $handle, bool $useCache = true): DidDocument 230 + Resolver::handleToDid(string $handle, bool $useCache = true): string 231 + Resolver::resolveHandle(string $handle, bool $useCache = true): DidDocument 232 232 233 233 // Identity Resolution 234 - Beacon::resolveIdentity(string $actor, bool $useCache = true): DidDocument 234 + Resolver::resolveIdentity(string $actor, bool $useCache = true): DidDocument 235 235 236 236 // PDS Resolution 237 - Beacon::resolvePds(string $actor, bool $useCache = true): ?string 237 + Resolver::resolvePds(string $actor, bool $useCache = true): ?string 238 238 239 239 // Cache Management 240 - Beacon::clearDidCache(string $did): void 241 - Beacon::clearHandleCache(string $handle): void 242 - Beacon::clearPdsCache(string $actor): void 243 - Beacon::clearCache(): void 240 + Resolver::clearDidCache(string $did): void 241 + Resolver::clearHandleCache(string $handle): void 242 + Resolver::clearPdsCache(string $actor): void 243 + Resolver::clearCache(): void 244 244 245 245 // Identity Validation (static helpers) 246 246 Identity::isHandle(?string $handle): bool ··· 270 270 Beacon throws descriptive exceptions when resolution fails: 271 271 272 272 ```php 273 - use SocialDept\Beacon\Exceptions\DidResolutionException; 274 - use SocialDept\Beacon\Exceptions\HandleResolutionException; 273 + use SocialDept\Resolver\Exceptions\DidResolutionException; 274 + use SocialDept\Resolver\Exceptions\HandleResolutionException; 275 275 276 276 try { 277 - $document = Beacon::resolveDid('did:invalid:format'); 277 + $document = Resolver::resolveDid('did:invalid:format'); 278 278 } catch (DidResolutionException $e) { 279 279 // Handle DID resolution errors 280 280 logger()->error('DID resolution failed', [ ··· 283 283 } 284 284 285 285 try { 286 - $did = Beacon::handleToDid('invalid-handle'); 286 + $did = Resolver::handleToDid('invalid-handle'); 287 287 } catch (HandleResolutionException $e) { 288 288 // Handle handle resolution errors 289 289 } ··· 295 295 296 296 ```php 297 297 // Resolve user identity from DID 298 - $document = Beacon::resolveDid($event->did); 298 + $document = Resolver::resolveDid($event->did); 299 299 $handle = $document->getHandle(); 300 300 301 301 // Make authenticated requests to their PDS 302 - $pds = Beacon::resolvePds($event->did); 302 + $pds = Resolver::resolvePds($event->did); 303 303 $client = new AtProtoClient($pds); 304 304 ``` 305 305 ··· 308 308 ```php 309 309 // Resolve multiple handles efficiently (caching kicks in) 310 310 $dids = collect(['alice.bsky.social', 'bob.bsky.social']) 311 - ->map(fn($handle) => Beacon::handleToDid($handle)) 311 + ->map(fn($handle) => Resolver::handleToDid($handle)) 312 312 ->all(); 313 313 ``` 314 314 ··· 316 316 317 317 ```php 318 318 // Get complete identity information 319 - $document = Beacon::resolveIdentity($username); 319 + $document = Resolver::resolveIdentity($username); 320 320 321 321 $profile = [ 322 322 'did' => $document->id, ··· 328 328 ### Input Validation 329 329 330 330 ```php 331 - use SocialDept\Beacon\Support\Identity; 332 - use SocialDept\Beacon\Facades\Beacon; 331 + use SocialDept\Resolver\Support\Identity; 332 + use SocialDept\Resolver\Facades\Resolver; 333 333 334 334 // Validate user input before resolving 335 335 $actor = request()->input('actor'); 336 336 337 337 if (Identity::isHandle($actor) || Identity::isDid($actor)) { 338 - $document = Beacon::resolveIdentity($actor); 338 + $document = Resolver::resolveIdentity($actor); 339 339 } else { 340 340 abort(422, 'Invalid handle or DID'); 341 341 } 342 342 343 343 // Or convert handle to DID 344 344 if (Identity::isHandle($actor)) { 345 - $did = Beacon::handleToDid($actor); 345 + $did = Resolver::handleToDid($actor); 346 346 } 347 347 ``` 348 348 ··· 361 361 362 362 ## Support & Contributing 363 363 364 - Found a bug or have a feature request? [Open an issue](https://github.com/socialdept/atp-beacon/issues). 364 + Found a bug or have a feature request? [Open an issue](https://github.com/socialdept/atp-resolver/issues). 365 365 366 366 Want to contribute? We'd love your help! Check out the [contribution guidelines](CONTRIBUTING.md). 367 367 368 368 ## Credits 369 369 370 370 - [Miguel Batres](https://batres.co) - founder & lead maintainer 371 - - [All contributors](https://github.com/socialdept/atp-beacon/graphs/contributors) 371 + - [All contributors](https://github.com/socialdept/atp-resolver/graphs/contributors) 372 372 373 373 ## License 374 374
+6 -6
composer.json
··· 1 1 { 2 - "name": "socialdept/atp-beacon", 3 - "description": "Resolve AT Protocol DIDs, handles, and lexicon schemas in Laravel", 2 + "name": "socialdept/atp-resolver", 3 + "description": "Resolve AT Protocol DIDs and handles in Laravel", 4 4 "type": "library", 5 5 "license": "MIT", 6 6 "require": { ··· 18 18 }, 19 19 "autoload": { 20 20 "psr-4": { 21 - "SocialDept\\Beacon\\": "src/" 21 + "SocialDept\\Resolver\\": "src/" 22 22 } 23 23 }, 24 24 "autoload-dev": { 25 25 "psr-4": { 26 - "SocialDept\\Beacon\\Tests\\": "tests/" 26 + "SocialDept\\Resolver\\Tests\\": "tests/" 27 27 } 28 28 }, 29 29 "extra": { 30 30 "laravel": { 31 31 "providers": [ 32 - "SocialDept\\Beacon\\BeaconServiceProvider" 32 + "SocialDept\\Resolver\\ResolverServiceProvider" 33 33 ], 34 34 "aliases": { 35 - "Beacon": "SocialDept\\Beacon\\Facades\\Beacon" 35 + "Resolver": "SocialDept\\Resolver\\Facades\\Resolver" 36 36 } 37 37 } 38 38 }
+10 -13
config/beacon.php config/resolver.php
··· 13 13 | 14 14 */ 15 15 16 - 'plc_directory' => env('BEACON_PLC_DIRECTORY', 'https://plc.directory'), 16 + 'plc_directory' => env('RESOLVER_PLC_DIRECTORY', 'https://plc.directory'), 17 17 18 18 /* 19 19 |-------------------------------------------------------------------------- ··· 25 25 | 26 26 */ 27 27 28 - 'pds_endpoint' => env('BEACON_PDS_ENDPOINT', 'https://bsky.social'), 28 + 'pds_endpoint' => env('RESOLVER_PDS_ENDPOINT', 'https://bsky.social'), 29 29 30 30 /* 31 31 |-------------------------------------------------------------------------- ··· 33 33 |-------------------------------------------------------------------------- 34 34 | 35 35 | The timeout in seconds for HTTP requests to external services when 36 - | resolving DIDs, handles, and lexicons. 36 + | resolving DIDs and handles. 37 37 | 38 38 */ 39 39 40 - 'timeout' => env('BEACON_TIMEOUT', 10), 40 + 'timeout' => env('RESOLVER_TIMEOUT', 10), 41 41 42 42 /* 43 43 |-------------------------------------------------------------------------- 44 44 | Cache Configuration 45 45 |-------------------------------------------------------------------------- 46 46 | 47 - | Configure caching behavior for resolved DIDs, handles, and lexicons. 47 + | Configure caching behavior for resolved DIDs and handles. 48 48 | TTL values are in seconds. 49 49 | 50 50 */ ··· 52 52 'cache' => [ 53 53 54 54 // Enable or disable caching globally 55 - 'enabled' => env('BEACON_CACHE_ENABLED', true), 55 + 'enabled' => env('RESOLVER_CACHE_ENABLED', true), 56 56 57 57 // Cache TTL for DID documents (1 hour default) 58 - 'did_ttl' => env('BEACON_CACHE_DID_TTL', 3600), 58 + 'did_ttl' => env('RESOLVER_CACHE_DID_TTL', 3600), 59 59 60 60 // Cache TTL for handle resolutions (1 hour default) 61 - 'handle_ttl' => env('BEACON_CACHE_HANDLE_TTL', 3600), 61 + 'handle_ttl' => env('RESOLVER_CACHE_HANDLE_TTL', 3600), 62 62 63 63 // Cache TTL for PDS endpoints (1 hour default) 64 - 'pds_ttl' => env('BEACON_CACHE_PDS_TTL', 3600), 65 - 66 - // Cache TTL for lexicon schemas (24 hours default) 67 - 'lexicon_ttl' => env('BEACON_CACHE_LEXICON_TTL', 86400), 64 + 'pds_ttl' => env('RESOLVER_CACHE_PDS_TTL', 3600), 68 65 69 66 ], 70 67 71 - ]; 68 + ];
header.png

This is a binary file and will not be displayed.

+14 -14
src/Beacon.php src/Resolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon; 3 + namespace SocialDept\Resolver; 4 4 5 - use SocialDept\Beacon\Contracts\CacheStore; 6 - use SocialDept\Beacon\Contracts\DidResolver; 7 - use SocialDept\Beacon\Contracts\HandleResolver; 8 - use SocialDept\Beacon\Data\DidDocument; 9 - use SocialDept\Beacon\Exceptions\DidResolutionException; 10 - use SocialDept\Beacon\Exceptions\HandleResolutionException; 11 - use SocialDept\Beacon\Support\Concerns\HasConfig; 12 - use SocialDept\Beacon\Support\Identity; 5 + use SocialDept\Resolver\Contracts\CacheStore; 6 + use SocialDept\Resolver\Contracts\DidResolver; 7 + use SocialDept\Resolver\Contracts\HandleResolver; 8 + use SocialDept\Resolver\Data\DidDocument; 9 + use SocialDept\Resolver\Exceptions\DidResolutionException; 10 + use SocialDept\Resolver\Exceptions\HandleResolutionException; 11 + use SocialDept\Resolver\Support\Concerns\HasConfig; 12 + use SocialDept\Resolver\Support\Identity; 13 13 14 - class Beacon 14 + class Resolver 15 15 { 16 16 use HasConfig; 17 17 18 18 /** 19 - * Create a new Beacon instance. 19 + * Create a new Resolver instance. 20 20 */ 21 21 public function __construct( 22 22 protected DidResolver $didResolver, ··· 48 48 $document = $this->didResolver->resolve($did); 49 49 50 50 if ($useCache) { 51 - $ttl = $this->getConfig('beacon.cache.did_ttl', 3600); 51 + $ttl = $this->getConfig('resolver.cache.did_ttl', 3600); 52 52 $this->cache->put($cacheKey, $document, $ttl); 53 53 } 54 54 ··· 74 74 $did = $this->handleResolver->resolve($handle); 75 75 76 76 if ($useCache) { 77 - $ttl = $this->getConfig('beacon.cache.handle_ttl', 3600); 77 + $ttl = $this->getConfig('resolver.cache.handle_ttl', 3600); 78 78 $this->cache->put($cacheKey, $did, $ttl); 79 79 } 80 80 ··· 164 164 $pdsEndpoint = $document->getPdsEndpoint(); 165 165 166 166 if ($useCache && $pdsEndpoint !== null) { 167 - $ttl = $this->getConfig('beacon.cache.pds_ttl', 3600); 167 + $ttl = $this->getConfig('resolver.cache.pds_ttl', 3600); 168 168 $this->cache->put($cacheKey, $pdsEndpoint, $ttl); 169 169 } 170 170
+16 -16
src/BeaconServiceProvider.php src/ResolverServiceProvider.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon; 3 + namespace SocialDept\Resolver; 4 4 5 5 use Illuminate\Support\ServiceProvider; 6 - use SocialDept\Beacon\Cache\LaravelCacheStore; 7 - use SocialDept\Beacon\Contracts\CacheStore; 8 - use SocialDept\Beacon\Contracts\DidResolver; 9 - use SocialDept\Beacon\Contracts\HandleResolver; 10 - use SocialDept\Beacon\Resolvers\AtProtoHandleResolver; 11 - use SocialDept\Beacon\Resolvers\DidResolverManager; 6 + use SocialDept\Resolver\Cache\LaravelCacheStore; 7 + use SocialDept\Resolver\Contracts\CacheStore; 8 + use SocialDept\Resolver\Contracts\DidResolver; 9 + use SocialDept\Resolver\Contracts\HandleResolver; 10 + use SocialDept\Resolver\Resolvers\AtProtoHandleResolver; 11 + use SocialDept\Resolver\Resolvers\DidResolverManager; 12 12 13 - class BeaconServiceProvider extends ServiceProvider 13 + class ResolverServiceProvider extends ServiceProvider 14 14 { 15 15 /** 16 16 * Register any package services. 17 17 */ 18 18 public function register(): void 19 19 { 20 - $this->mergeConfigFrom(__DIR__.'/../config/beacon.php', 'beacon'); 20 + $this->mergeConfigFrom(__DIR__.'/../config/resolver.php', 'resolver'); 21 21 22 22 // Register cache store 23 23 $this->app->singleton(CacheStore::class, function ($app) { ··· 34 34 return new AtProtoHandleResolver(); 35 35 }); 36 36 37 - // Register Beacon service 38 - $this->app->singleton('beacon', function ($app) { 39 - return new Beacon( 37 + // Register Resolver service 38 + $this->app->singleton('resolver', function ($app) { 39 + return new Resolver( 40 40 $app->make(DidResolver::class), 41 41 $app->make(HandleResolver::class), 42 42 $app->make(CacheStore::class), 43 43 ); 44 44 }); 45 45 46 - $this->app->alias('beacon', Beacon::class); 46 + $this->app->alias('resolver', Resolver::class); 47 47 } 48 48 49 49 /** ··· 63 63 */ 64 64 public function provides(): array 65 65 { 66 - return ['beacon', Beacon::class]; 66 + return ['resolver', Resolver::class]; 67 67 } 68 68 69 69 /** ··· 73 73 { 74 74 // Publish config 75 75 $this->publishes([ 76 - __DIR__.'/../config/beacon.php' => config_path('beacon.php'), 77 - ], 'beacon-config'); 76 + __DIR__.'/../config/resolver.php' => config_path('resolver.php'), 77 + ], 'resolver-config'); 78 78 } 79 79 }
+2 -2
src/Cache/LaravelCacheStore.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Cache; 3 + namespace SocialDept\Resolver\Cache; 4 4 5 5 use Illuminate\Contracts\Cache\Repository; 6 - use SocialDept\Beacon\Contracts\CacheStore; 6 + use SocialDept\Resolver\Contracts\CacheStore; 7 7 8 8 class LaravelCacheStore implements CacheStore 9 9 {
+1 -1
src/Contracts/CacheStore.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Contracts; 3 + namespace SocialDept\Resolver\Contracts; 4 4 5 5 interface CacheStore 6 6 {
+3 -3
src/Contracts/DidResolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Contracts; 3 + namespace SocialDept\Resolver\Contracts; 4 4 5 - use SocialDept\Beacon\Data\DidDocument; 5 + use SocialDept\Resolver\Data\DidDocument; 6 6 7 7 interface DidResolver 8 8 { ··· 12 12 * @param string $did The DID to resolve (e.g., "did:plc:abc123" or "did:web:example.com") 13 13 * @return DidDocument 14 14 * 15 - * @throws \SocialDept\Beacon\Exceptions\DidResolutionException 15 + * @throws \SocialDept\Resolver\Exceptions\DidResolutionException 16 16 */ 17 17 public function resolve(string $did): DidDocument; 18 18
+2 -2
src/Contracts/HandleResolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Contracts; 3 + namespace SocialDept\Resolver\Contracts; 4 4 5 5 interface HandleResolver 6 6 { ··· 10 10 * @param string $handle The handle to resolve (e.g., "user.bsky.social") 11 11 * @return string The resolved DID 12 12 * 13 - * @throws \SocialDept\Beacon\Exceptions\HandleResolutionException 13 + * @throws \SocialDept\Resolver\Exceptions\HandleResolutionException 14 14 */ 15 15 public function resolve(string $handle): string; 16 16 }
+1 -1
src/Data/DidDocument.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Data; 3 + namespace SocialDept\Resolver\Data; 4 4 5 5 class DidDocument 6 6 {
-10
src/Exceptions/BeaconException.php
··· 1 - <?php 2 - 3 - namespace SocialDept\Beacon\Exceptions; 4 - 5 - use Exception; 6 - 7 - class BeaconException extends Exception 8 - { 9 - // 10 - }
+2 -2
src/Exceptions/DidResolutionException.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Exceptions; 3 + namespace SocialDept\Resolver\Exceptions; 4 4 5 - class DidResolutionException extends BeaconException 5 + class DidResolutionException extends ResolverException 6 6 { 7 7 /** 8 8 * Create a new exception for unsupported DID method.
+2 -2
src/Exceptions/HandleResolutionException.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Exceptions; 3 + namespace SocialDept\Resolver\Exceptions; 4 4 5 - class HandleResolutionException extends BeaconException 5 + class HandleResolutionException extends ResolverException 6 6 { 7 7 /** 8 8 * Create a new exception for invalid handle format.
+10
src/Exceptions/ResolverException.php
··· 1 + <?php 2 + 3 + namespace SocialDept\Resolver\Exceptions; 4 + 5 + use Exception; 6 + 7 + class ResolverException extends Exception 8 + { 9 + // 10 + }
+3 -3
src/Facades/Beacon.php src/Facades/Resolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Facades; 3 + namespace SocialDept\Resolver\Facades; 4 4 5 5 use Illuminate\Support\Facades\Facade; 6 6 7 - class Beacon extends Facade 7 + class Resolver extends Facade 8 8 { 9 9 /** 10 10 * Get the registered name of the component. ··· 13 13 */ 14 14 protected static function getFacadeAccessor(): string 15 15 { 16 - return 'beacon'; 16 + return 'resolver'; 17 17 } 18 18 }
+6 -6
src/Resolvers/AtProtoHandleResolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Resolvers; 3 + namespace SocialDept\Resolver\Resolvers; 4 4 5 5 use GuzzleHttp\Client; 6 6 use GuzzleHttp\Exception\GuzzleException; 7 - use SocialDept\Beacon\Contracts\HandleResolver; 8 - use SocialDept\Beacon\Exceptions\HandleResolutionException; 9 - use SocialDept\Beacon\Support\Concerns\HasConfig; 7 + use SocialDept\Resolver\Contracts\HandleResolver; 8 + use SocialDept\Resolver\Exceptions\HandleResolutionException; 9 + use SocialDept\Resolver\Support\Concerns\HasConfig; 10 10 11 11 class AtProtoHandleResolver implements HandleResolver 12 12 { ··· 23 23 */ 24 24 public function __construct(?string $pdsEndpoint = null, ?int $timeout = null) 25 25 { 26 - $this->pdsEndpoint = $pdsEndpoint ?? $this->getConfig('beacon.pds_endpoint', 'https://bsky.social'); 26 + $this->pdsEndpoint = $pdsEndpoint ?? $this->getConfig('resolver.pds_endpoint', 'https://bsky.social'); 27 27 $this->client = new Client([ 28 - 'timeout' => $timeout ?? $this->getConfig('beacon.timeout', 10), 28 + 'timeout' => $timeout ?? $this->getConfig('resolver.timeout', 10), 29 29 'headers' => [ 30 30 'Accept' => 'application/json', 31 31 'User-Agent' => 'Beacon/1.0',
+5 -5
src/Resolvers/DidResolverManager.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Resolvers; 3 + namespace SocialDept\Resolver\Resolvers; 4 4 5 - use SocialDept\Beacon\Contracts\DidResolver; 6 - use SocialDept\Beacon\Data\DidDocument; 7 - use SocialDept\Beacon\Exceptions\DidResolutionException; 8 - use SocialDept\Beacon\Support\Concerns\ParsesDid; 5 + use SocialDept\Resolver\Contracts\DidResolver; 6 + use SocialDept\Resolver\Data\DidDocument; 7 + use SocialDept\Resolver\Exceptions\DidResolutionException; 8 + use SocialDept\Resolver\Support\Concerns\ParsesDid; 9 9 10 10 class DidResolverManager implements DidResolver 11 11 {
+8 -8
src/Resolvers/PlcDidResolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Resolvers; 3 + namespace SocialDept\Resolver\Resolvers; 4 4 5 5 use GuzzleHttp\Client; 6 6 use GuzzleHttp\Exception\GuzzleException; 7 - use SocialDept\Beacon\Contracts\DidResolver; 8 - use SocialDept\Beacon\Data\DidDocument; 9 - use SocialDept\Beacon\Exceptions\DidResolutionException; 10 - use SocialDept\Beacon\Support\Concerns\HasConfig; 11 - use SocialDept\Beacon\Support\Concerns\ParsesDid; 7 + use SocialDept\Resolver\Contracts\DidResolver; 8 + use SocialDept\Resolver\Data\DidDocument; 9 + use SocialDept\Resolver\Exceptions\DidResolutionException; 10 + use SocialDept\Resolver\Support\Concerns\HasConfig; 11 + use SocialDept\Resolver\Support\Concerns\ParsesDid; 12 12 13 13 class PlcDidResolver implements DidResolver 14 14 { ··· 26 26 */ 27 27 public function __construct(?string $plcDirectory = null, ?int $timeout = null) 28 28 { 29 - $this->plcDirectory = $plcDirectory ?? $this->getConfig('beacon.plc_directory', 'https://plc.directory'); 29 + $this->plcDirectory = $plcDirectory ?? $this->getConfig('resolver.plc_directory', 'https://plc.directory'); 30 30 $this->client = new Client([ 31 - 'timeout' => $timeout ?? $this->getConfig('beacon.timeout', 10), 31 + 'timeout' => $timeout ?? $this->getConfig('resolver.timeout', 10), 32 32 'headers' => [ 33 33 'Accept' => 'application/json', 34 34 'User-Agent' => 'Beacon/1.0',
+7 -7
src/Resolvers/WebDidResolver.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Resolvers; 3 + namespace SocialDept\Resolver\Resolvers; 4 4 5 5 use GuzzleHttp\Client; 6 6 use GuzzleHttp\Exception\GuzzleException; 7 - use SocialDept\Beacon\Contracts\DidResolver; 8 - use SocialDept\Beacon\Data\DidDocument; 9 - use SocialDept\Beacon\Exceptions\DidResolutionException; 10 - use SocialDept\Beacon\Support\Concerns\HasConfig; 11 - use SocialDept\Beacon\Support\Concerns\ParsesDid; 7 + use SocialDept\Resolver\Contracts\DidResolver; 8 + use SocialDept\Resolver\Data\DidDocument; 9 + use SocialDept\Resolver\Exceptions\DidResolutionException; 10 + use SocialDept\Resolver\Support\Concerns\HasConfig; 11 + use SocialDept\Resolver\Support\Concerns\ParsesDid; 12 12 13 13 class WebDidResolver implements DidResolver 14 14 { ··· 23 23 public function __construct(?int $timeout = null) 24 24 { 25 25 $this->client = new Client([ 26 - 'timeout' => $timeout ?? $this->getConfig('beacon.timeout', 10), 26 + 'timeout' => $timeout ?? $this->getConfig('resolver.timeout', 10), 27 27 'headers' => [ 28 28 'Accept' => 'application/json', 29 29 'User-Agent' => 'Beacon/1.0',
+1 -1
src/Support/Concerns/HasConfig.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Support\Concerns; 3 + namespace SocialDept\Resolver\Support\Concerns; 4 4 5 5 trait HasConfig 6 6 {
+2 -2
src/Support/Concerns/ParsesDid.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Support\Concerns; 3 + namespace SocialDept\Resolver\Support\Concerns; 4 4 5 - use SocialDept\Beacon\Exceptions\DidResolutionException; 5 + use SocialDept\Resolver\Exceptions\DidResolutionException; 6 6 7 7 trait ParsesDid 8 8 {
+1 -1
src/Support/Identity.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Support; 3 + namespace SocialDept\Resolver\Support; 4 4 5 5 class Identity 6 6 {
+11 -11
tests/Unit/BeaconIdentityTest.php tests/Unit/ResolverIdentityTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Beacon; 7 - use SocialDept\Beacon\Contracts\CacheStore; 8 - use SocialDept\Beacon\Contracts\DidResolver; 9 - use SocialDept\Beacon\Contracts\HandleResolver; 10 - use SocialDept\Beacon\Data\DidDocument; 6 + use SocialDept\Resolver\Resolver; 7 + use SocialDept\Resolver\Contracts\CacheStore; 8 + use SocialDept\Resolver\Contracts\DidResolver; 9 + use SocialDept\Resolver\Contracts\HandleResolver; 10 + use SocialDept\Resolver\Data\DidDocument; 11 11 12 - class BeaconIdentityTest extends TestCase 12 + class ResolverIdentityTest extends TestCase 13 13 { 14 14 public function test_it_can_convert_handle_to_did(): void 15 15 { ··· 27 27 ->method('put') 28 28 ->with('handle:user.bsky.social', 'did:plc:abc123', $this->anything()); 29 29 30 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 30 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 31 31 $did = $beacon->handleToDid('user.bsky.social'); 32 32 33 33 $this->assertSame('did:plc:abc123', $did); ··· 56 56 57 57 $cache->method('has')->willReturn(false); 58 58 59 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 59 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 60 60 $document = $beacon->resolveHandle('user.bsky.social'); 61 61 62 62 $this->assertInstanceOf(DidDocument::class, $document); ··· 81 81 $cache->method('has')->willReturn(false); 82 82 $handleResolver->expects($this->never())->method('resolve'); 83 83 84 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 84 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 85 85 $document = $beacon->resolveIdentity('did:plc:abc123'); 86 86 87 87 $this->assertInstanceOf(DidDocument::class, $document); ··· 111 111 112 112 $cache->method('has')->willReturn(false); 113 113 114 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 114 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 115 115 $document = $beacon->resolveIdentity('user.bsky.social'); 116 116 117 117 $this->assertInstanceOf(DidDocument::class, $document);
+12 -12
tests/Unit/BeaconTest.php tests/Unit/ResolverTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Beacon; 7 - use SocialDept\Beacon\Contracts\CacheStore; 8 - use SocialDept\Beacon\Contracts\DidResolver; 9 - use SocialDept\Beacon\Contracts\HandleResolver; 10 - use SocialDept\Beacon\Data\DidDocument; 6 + use SocialDept\Resolver\Resolver; 7 + use SocialDept\Resolver\Contracts\CacheStore; 8 + use SocialDept\Resolver\Contracts\DidResolver; 9 + use SocialDept\Resolver\Contracts\HandleResolver; 10 + use SocialDept\Resolver\Data\DidDocument; 11 11 12 - class BeaconTest extends TestCase 12 + class ResolverTest extends TestCase 13 13 { 14 14 public function test_it_can_resolve_pds_from_did(): void 15 15 { ··· 43 43 return null; 44 44 }); 45 45 46 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 46 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 47 47 $pds = $beacon->resolvePds('did:plc:abc123'); 48 48 49 49 $this->assertSame('https://pds.example.com', $pds); ··· 86 86 return null; 87 87 }); 88 88 89 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 89 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 90 90 $pds = $beacon->resolvePds('user.bsky.social'); 91 91 92 92 $this->assertSame('https://pds.example.com', $pds); ··· 115 115 ->method('put') 116 116 ->with('did:did:plc:abc123', $didDocument, $this->anything()); 117 117 118 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 118 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 119 119 $pds = $beacon->resolvePds('did:plc:abc123'); 120 120 121 121 $this->assertNull($pds); ··· 139 139 140 140 $didResolver->expects($this->never())->method('resolve'); 141 141 142 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 142 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 143 143 $pds = $beacon->resolvePds('did:plc:abc123'); 144 144 145 145 $this->assertSame('https://cached-pds.example.com', $pds); ··· 155 155 ->method('forget') 156 156 ->with('pds:did:plc:abc123'); 157 157 158 - $beacon = new Beacon($didResolver, $handleResolver, $cache); 158 + $beacon = new Resolver($didResolver, $handleResolver, $cache); 159 159 $beacon->clearPdsCache('did:plc:abc123'); 160 160 } 161 161 }
+2 -2
tests/Unit/DidDocumentTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Data\DidDocument; 6 + use SocialDept\Resolver\Data\DidDocument; 7 7 8 8 class DidDocumentTest extends TestCase 9 9 {
+5 -5
tests/Unit/DidResolverManagerTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Contracts\DidResolver; 7 - use SocialDept\Beacon\Data\DidDocument; 8 - use SocialDept\Beacon\Exceptions\DidResolutionException; 9 - use SocialDept\Beacon\Resolvers\DidResolverManager; 6 + use SocialDept\Resolver\Contracts\DidResolver; 7 + use SocialDept\Resolver\Data\DidDocument; 8 + use SocialDept\Resolver\Exceptions\DidResolutionException; 9 + use SocialDept\Resolver\Resolvers\DidResolverManager; 10 10 11 11 class DidResolverManagerTest extends TestCase 12 12 {
+2 -2
tests/Unit/IdentityTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Support\Identity; 6 + use SocialDept\Resolver\Support\Identity; 7 7 8 8 class IdentityTest extends TestCase 9 9 {
+3 -3
tests/Unit/PlcDidResolverTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Exceptions\DidResolutionException; 7 - use SocialDept\Beacon\Resolvers\PlcDidResolver; 6 + use SocialDept\Resolver\Exceptions\DidResolutionException; 7 + use SocialDept\Resolver\Resolvers\PlcDidResolver; 8 8 9 9 class PlcDidResolverTest extends TestCase 10 10 {
+3 -3
tests/Unit/WebDidResolverTest.php
··· 1 1 <?php 2 2 3 - namespace SocialDept\Beacon\Tests\Unit; 3 + namespace SocialDept\Resolver\Tests\Unit; 4 4 5 5 use PHPUnit\Framework\TestCase; 6 - use SocialDept\Beacon\Exceptions\DidResolutionException; 7 - use SocialDept\Beacon\Resolvers\WebDidResolver; 6 + use SocialDept\Resolver\Exceptions\DidResolutionException; 7 + use SocialDept\Resolver\Resolvers\WebDidResolver; 8 8 9 9 class WebDidResolverTest extends TestCase 10 10 {