2021-07-21 23:04:00 +00:00
|
|
|
package token
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-10-17 22:51:10 +00:00
|
|
|
"errors"
|
2021-09-20 18:25:08 +00:00
|
|
|
|
2022-01-04 17:31:33 +00:00
|
|
|
"source.toby3d.me/website/indieauth/internal/domain"
|
2021-07-21 23:04:00 +00:00
|
|
|
)
|
|
|
|
|
2021-11-14 21:17:25 +00:00
|
|
|
type (
|
2022-01-13 20:49:08 +00:00
|
|
|
ExchangeOptions struct {
|
|
|
|
ClientID *domain.ClientID
|
|
|
|
RedirectURI *domain.URL
|
|
|
|
Code string
|
|
|
|
CodeVerifier string
|
2021-11-14 21:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UseCase interface {
|
2022-01-13 20:49:08 +00:00
|
|
|
Exchange(ctx context.Context, opts ExchangeOptions) (*domain.Token, error)
|
2021-11-14 21:17:25 +00:00
|
|
|
|
|
|
|
// Verify checks the AccessToken and returns the associated information.
|
|
|
|
Verify(ctx context.Context, accessToken string) (*domain.Token, error)
|
|
|
|
|
|
|
|
// Revoke revokes the AccessToken and blocks its further use.
|
|
|
|
Revoke(ctx context.Context, accessToken string) error
|
|
|
|
}
|
|
|
|
)
|
2021-10-17 22:51:10 +00:00
|
|
|
|
2021-10-17 23:12:00 +00:00
|
|
|
var ErrRevoke = errors.New("this token has been revoked")
|