types.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package toc
  2. import (
  3. "context"
  4. "net"
  5. "time"
  6. "github.com/mk6i/open-oscar-server/config"
  7. "github.com/mk6i/open-oscar-server/state"
  8. "github.com/mk6i/open-oscar-server/wire"
  9. )
  10. // OSCARServer serves OSCAR connections that the TOC server opens on behalf of
  11. // its users.
  12. type OSCARServer interface {
  13. // ServeConn serves conn as if it had been accepted on the listener at
  14. // endpointCfg, and returns when the connection ends.
  15. ServeConn(conn net.Conn, endpointCfg config.Endpoint)
  16. }
  17. // LocateService looks up user profiles and directory info for the TOC HTTP
  18. // pages.
  19. type LocateService interface {
  20. UserInfoQuery(ctx context.Context, instance *state.SessionInstance, inFrame wire.SNACFrame, inBody wire.SNAC_0x02_0x05_LocateUserInfoQuery) (wire.SNACMessage, error)
  21. DirInfo(ctx context.Context, inFrame wire.SNACFrame, inBody wire.SNAC_0x02_0x0B_LocateGetDirInfo) (wire.SNACMessage, error)
  22. }
  23. // DirSearchService searches the user directory for the TOC HTTP pages.
  24. type DirSearchService interface {
  25. InfoQuery(ctx context.Context, inFrame wire.SNACFrame, inBody wire.SNAC_0x0F_0x02_InfoQuery) (wire.SNACMessage, error)
  26. }
  27. // TOCConfigStore loads and saves users' TOC configs.
  28. type TOCConfigStore interface {
  29. // SetTOCConfig sets the user's TOC config. The TOC config is the server-side
  30. // buddy list functionality for TOC. This configuration is not available to
  31. // OSCAR clients.
  32. SetTOCConfig(ctx context.Context, user state.IdentScreenName, config string) error
  33. User(ctx context.Context, screenName state.IdentScreenName) (*state.User, error)
  34. }
  35. // CookieBaker defines methods for issuing and verifying AIM authentication tokens ("cookies").
  36. // These tokens are used for authenticating client sessions with AIM services.
  37. type CookieBaker interface {
  38. // Crack verifies and decodes a previously issued authentication token.
  39. // Returns the original payload and the token's expiry if it is valid.
  40. Crack(data []byte) ([]byte, time.Time, error)
  41. // Issue creates a new authentication token from the given payload that
  42. // stays valid for ttl. The resulting token can later be verified using
  43. // Crack.
  44. Issue(data []byte, ttl time.Duration) ([]byte, error)
  45. }
  46. // SessionRetriever defines a method for retrieving an active session
  47. // associated with a given screen name.
  48. type SessionRetriever interface {
  49. // RetrieveSession returns the session associated with the given screen name,
  50. // or nil if no active session exists. Returns the Session object if there
  51. // are active instances with complete signon.
  52. RetrieveSession(screenName state.IdentScreenName) *state.Session
  53. }