TokenStore defines the interface for storing and retrieving refresh tokens
| 17 | |
| 18 | // TokenStore defines the interface for storing and retrieving refresh tokens |
| 19 | type TokenStore interface { |
| 20 | // Set stores a refresh token with associated user data and expiration |
| 21 | // Returns an error if the operation fails |
| 22 | Set(ctx context.Context, token string, userData any, expiry time.Time) error |
| 23 | |
| 24 | // Get retrieves user data associated with a refresh token |
| 25 | // Returns ErrRefreshTokenNotFound if token doesn't exist or is expired |
| 26 | Get(ctx context.Context, token string) (any, error) |
| 27 | |
| 28 | // Delete removes a refresh token from storage |
| 29 | // Returns an error if the operation fails, but should not error if token doesn't exist |
| 30 | Delete(ctx context.Context, token string) error |
| 31 | |
| 32 | // Cleanup removes expired tokens (optional, for cleanup routines) |
| 33 | // Returns the number of tokens cleaned up and any error encountered |
| 34 | Cleanup(ctx context.Context) (int, error) |
| 35 | |
| 36 | // Count returns the total number of active refresh tokens |
| 37 | // Useful for monitoring and debugging |
| 38 | Count(ctx context.Context) (int, error) |
| 39 | } |
| 40 | |
| 41 | // RefreshTokenData holds the data stored with each refresh token |
| 42 | type RefreshTokenData struct { |
no outgoing calls
no test coverage detected
searching dependent graphs…