Laravel AT Protocol Client (alpha & unstable)
1<?php
2
3namespace SocialDept\AtpClient\Providers;
4
5use SocialDept\AtpClient\Contracts\CredentialProvider;
6use SocialDept\AtpClient\Data\AccessToken;
7use SocialDept\AtpClient\Data\Credentials;
8
9class ArrayCredentialProvider implements CredentialProvider
10{
11 /**
12 * In-memory credential storage.
13 *
14 * @var array<string, Credentials>
15 */
16 protected array $credentials = [];
17
18 public function getCredentials(string $did): ?Credentials
19 {
20 return $this->credentials[$did] ?? null;
21 }
22
23 public function storeCredentials(string $did, AccessToken $token): void
24 {
25 $this->credentials[$did] = new Credentials(
26 did: $token->did,
27 accessToken: $token->accessJwt,
28 refreshToken: $token->refreshJwt,
29 expiresAt: $token->expiresAt,
30 handle: $token->handle,
31 issuer: $token->issuer,
32 scope: $token->scope,
33 authType: $token->authType,
34 );
35 }
36
37 public function updateCredentials(string $did, AccessToken $token): void
38 {
39 $this->storeCredentials($did, $token);
40 }
41
42 public function removeCredentials(string $did): void
43 {
44 unset($this->credentials[$did]);
45 }
46}