mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-08-31 23:36:57 +00:00
51 lines
1.5 KiB
Go
51 lines
1.5 KiB
Go
package appview
|
|
|
|
import "time"
|
|
|
|
// SessionStore interface for UI session management
|
|
// Implemented by both session.Store (file-based) and db.SessionStore (SQLite-based)
|
|
type SessionStore interface {
|
|
Create(did, handle, pdsEndpoint string, duration time.Duration) (string, error)
|
|
CreateWithOAuth(did, handle, pdsEndpoint, oauthSessionID string, duration time.Duration) (string, error)
|
|
Get(id string) (Session, bool)
|
|
Delete(id string)
|
|
Cleanup()
|
|
}
|
|
|
|
// Session represents a user session
|
|
// Compatible with both file-based and SQLite implementations
|
|
type Session interface {
|
|
GetID() string
|
|
GetDID() string
|
|
GetHandle() string
|
|
GetPDSEndpoint() string
|
|
GetOAuthSessionID() string
|
|
}
|
|
|
|
// DeviceStore interface for device authorization management
|
|
// Implemented by both device.Store (file-based) and db.DeviceStore (SQLite-based)
|
|
type DeviceStore interface {
|
|
CreatePendingAuth(deviceName, ip, userAgent string) (PendingAuth, error)
|
|
GetPendingByUserCode(userCode string) (PendingAuth, bool)
|
|
GetPendingByDeviceCode(deviceCode string) (PendingAuth, bool)
|
|
ApprovePending(userCode, did, handle string) (deviceSecret string, err error)
|
|
ValidateDeviceSecret(secret string) (Device, error)
|
|
ListDevices(did string) []Device
|
|
RevokeDevice(did, deviceID string) error
|
|
CleanupExpired()
|
|
}
|
|
|
|
// PendingAuth interface for pending device authorizations
|
|
type PendingAuth interface {
|
|
GetDeviceCode() string
|
|
GetUserCode() string
|
|
GetDeviceName() string
|
|
}
|
|
|
|
// Device interface for authorized devices
|
|
type Device interface {
|
|
GetID() string
|
|
GetDID() string
|
|
GetHandle() string
|
|
}
|