EIP712 TODO
This commit is contained in:
parent
723d883bc2
commit
6d16a6ea8c
@ -46,12 +46,18 @@ type User struct {
|
|||||||
DeletedAt *time.Time
|
DeletedAt *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to another file?
|
||||||
type Challenge struct {
|
type Challenge struct {
|
||||||
Message uuid.UUID
|
Message uuid.UUID
|
||||||
TimeStamp time.Time
|
TimeStamp time.Time
|
||||||
ExpiresAt time.Time
|
ExpiresAt time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: check EIP712 in here for challenge validation
|
||||||
|
func (c *Challenge) IsExpired() bool {
|
||||||
|
return time.Now().After(c.ExpiresAt)
|
||||||
|
}
|
||||||
|
|
||||||
func NewUser(pubKey, name, lastName, phoneNumber, email, nationalID string) (*User, error) {
|
func NewUser(pubKey, name, lastName, phoneNumber, email, nationalID string) (*User, error) {
|
||||||
|
|
||||||
_, err := phone.IsValid(phoneNumber)
|
_, err := phone.IsValid(phoneNumber)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
type AuthService interface {
|
type AuthService interface {
|
||||||
GenerateChallenge(ctx context.Context, pubKey string) (*domain.Challenge, error)
|
GenerateChallenge(ctx context.Context, pubKey string) (*domain.Challenge, error)
|
||||||
|
Authenticate(ctx context.Context, pubKey string, signature string, challenge *domain.Challenge, chainID uint) (*UserToken, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type authService struct {
|
type authService struct {
|
||||||
@ -21,6 +22,12 @@ type authService struct {
|
|||||||
refreshTokenExp uint
|
refreshTokenExp uint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserToken struct {
|
||||||
|
AuthorizationToken string
|
||||||
|
RefreshToken string
|
||||||
|
ExpiresAt int64
|
||||||
|
}
|
||||||
|
|
||||||
func NewAuthService(
|
func NewAuthService(
|
||||||
userRepo *domain.UserRepo,
|
userRepo *domain.UserRepo,
|
||||||
sessionRepo *domain.SessionRepo,
|
sessionRepo *domain.SessionRepo,
|
||||||
@ -47,3 +54,7 @@ func (s *authService) GenerateChallenge(ctx context.Context, pubKey string) (*do
|
|||||||
}
|
}
|
||||||
return challenge, nil
|
return challenge, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *authService) Authenticate(ctx context.Context, pubKey string, signature string, challenge *domain.Challenge, chainID uint) (*UserToken, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user