2024-12-10 13:40:41 -05:00
|
|
|
package sessions
|
2024-12-05 20:36:58 -05:00
|
|
|
|
2024-12-06 21:31:20 -05:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrInvalidCredentials = echo.NewHTTPError(http.StatusUnauthorized, "Invalid credentials")
|
|
|
|
ErrInvalidSubject = echo.NewHTTPError(http.StatusBadRequest, "Invalid subject")
|
|
|
|
ErrInvalidUser = echo.NewHTTPError(http.StatusBadRequest, "Invalid user")
|
|
|
|
|
|
|
|
ErrUserAlreadyExists = echo.NewHTTPError(http.StatusConflict, "User already exists")
|
|
|
|
ErrUserNotFound = echo.NewHTTPError(http.StatusNotFound, "User not found")
|
|
|
|
)
|
|
|
|
|
2024-12-09 16:23:18 -05:00
|
|
|
// Define the credential structure matching our frontend data
|
|
|
|
type Credential struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
RawID string `json:"rawId"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
AuthenticatorAttachment string `json:"authenticatorAttachment"`
|
|
|
|
Transports []string `json:"transports"`
|
|
|
|
ClientExtensionResults map[string]interface{} `json:"clientExtensionResults"`
|
|
|
|
Response struct {
|
|
|
|
AttestationObject string `json:"attestationObject"`
|
|
|
|
ClientDataJSON string `json:"clientDataJSON"`
|
|
|
|
} `json:"response"`
|
|
|
|
}
|
|
|
|
|
2024-12-06 21:31:20 -05:00
|
|
|
type User struct {
|
|
|
|
gorm.Model
|
2024-12-09 16:23:18 -05:00
|
|
|
Address string `json:"address"`
|
|
|
|
Handle string `json:"handle"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
CID string `json:"cid"`
|
|
|
|
Credentials []*Credential `json:"credentials"`
|
2024-12-06 21:31:20 -05:00
|
|
|
}
|
|
|
|
|
2024-12-05 20:36:58 -05:00
|
|
|
type Session struct {
|
2024-12-06 21:31:20 -05:00
|
|
|
gorm.Model
|
|
|
|
ID string `json:"id" gorm:"primaryKey"`
|
2024-12-05 20:36:58 -05:00
|
|
|
BrowserName string `json:"browserName"`
|
|
|
|
BrowserVersion string `json:"browserVersion"`
|
|
|
|
UserArchitecture string `json:"userArchitecture"`
|
|
|
|
Platform string `json:"platform"`
|
|
|
|
PlatformVersion string `json:"platformVersion"`
|
|
|
|
DeviceModel string `json:"deviceModel"`
|
2024-12-06 21:31:20 -05:00
|
|
|
UserHandle string `json:"userHandle"`
|
|
|
|
FirstName string `json:"firstName"`
|
|
|
|
LastInitial string `json:"lastInitial"`
|
|
|
|
VaultAddress string `json:"vaultAddress"`
|
2024-12-08 23:30:17 -05:00
|
|
|
HumanSum int `json:"humanSum"`
|
|
|
|
Challenge string `json:"challenge"`
|
2024-12-05 20:36:58 -05:00
|
|
|
}
|