types.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. type TOCConfigStore interface {
  28. // SetTOCConfig sets the user's TOC config. The TOC config is the server-side
  29. // buddy list functionality for TOC. This configuration is not available to
  30. // OSCAR clients.
  31. SetTOCConfig(ctx context.Context, user state.IdentScreenName, config string) error
  32. User(ctx context.Context, screenName state.IdentScreenName) (*state.User, error)
  33. }
  34. // CookieBaker defines methods for issuing and verifying AIM authentication tokens ("cookies").
  35. // These tokens are used for authenticating client sessions with AIM services.
  36. type CookieBaker interface {
  37. // Crack verifies and decodes a previously issued authentication token.
  38. // Returns the original payload and the token's expiry if it is valid.
  39. Crack(data []byte) ([]byte, time.Time, error)
  40. // Issue creates a new authentication token from the given payload that
  41. // stays valid for ttl. The resulting token can later be verified using
  42. // Crack.
  43. Issue(data []byte, ttl time.Duration) ([]byte, error)
  44. }
  45. // SessionRetriever defines a method for retrieving an active session
  46. // associated with a given screen name.
  47. type SessionRetriever interface {
  48. // RetrieveSession returns the session associated with the given screen name,
  49. // or nil if no active session exists. Returns the Session object if there
  50. // are active instances with complete signon.
  51. RetrieveSession(screenName state.IdentScreenName) *state.Session
  52. }