Documentation
¶
Overview ¶
Package device defines the device tracking domain entity and its store interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseUserAgent ¶
ParseUserAgent extracts browser, OS, and device type from a User-Agent string. Uses simple heuristic parsing to avoid external dependencies.
Types ¶
type Device ¶
type Device struct {
ID id.DeviceID `json:"id"`
UserID id.UserID `json:"user_id"`
AppID id.AppID `json:"app_id"`
EnvID id.EnvironmentID `json:"env_id"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Browser string `json:"browser,omitempty"`
OS string `json:"os,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
Fingerprint string `json:"fingerprint,omitempty"`
Trusted bool `json:"trusted"`
TrustedUntil *time.Time `json:"trusted_until,omitempty"`
LastSeenAt time.Time `json:"last_seen_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Device represents a tracked user device.
type Store ¶
type Store interface {
CreateDevice(ctx context.Context, d *Device) error
GetDevice(ctx context.Context, deviceID id.DeviceID) (*Device, error)
GetDeviceByFingerprint(ctx context.Context, userID id.UserID, fingerprint string) (*Device, error)
UpdateDevice(ctx context.Context, d *Device) error
DeleteDevice(ctx context.Context, deviceID id.DeviceID) error
ListUserDevices(ctx context.Context, userID id.UserID) ([]*Device, error)
// ListDevices returns the most recent devices across all users, up to limit.
ListDevices(ctx context.Context, limit int) ([]*Device, error)
}
Store defines the persistence interface for device tracking operations.
Click to show internal directories.
Click to hide internal directories.