chore: update session and challenge repo -- using Redis for caching session and challenge verifying -- added api handler docs

This commit is contained in:
2025-09-09 13:31:41 +03:30
parent dee9ce2f64
commit 6bf6a8ffc2
20 changed files with 1077 additions and 193 deletions
+8 -2
View File
@@ -32,6 +32,12 @@ type UserRepo interface {
Delete(ctx context.Context, id uuid.UUID) error
}
type ChallengeRepo interface {
Create(ctx context.Context, pubKey string, challenge *Challenge) error
GetByPubKey(ctx context.Context, pubKey string) (*Challenge, error)
Delete(ctx context.Context, pubKey string) error
}
type User struct {
ID uuid.UUID
PubKey string
@@ -51,7 +57,7 @@ type User struct {
// TODO: move to another file?
type Challenge struct {
Message uuid.UUID
Message string
TimeStamp time.Time
ExpiresAt time.Time
}
@@ -70,7 +76,7 @@ func (c *Challenge) Verify(address string, signedMsg string) (bool, error) {
return false, fmt.Errorf("decode signature: %w", err)
}
challengeBytes := []byte(c.Message.String())
challengeBytes := []byte(c.Message)
return c.VerifySignedBytes(address, challengeBytes, signature)
}