Skip to content

Class BSV::Auth::SessionManager

Inherits: Object

Thread-safe store for {PeerSession} objects.

Supports dual-index lookup: by session_nonce (primary) or by peer_identity_key (secondary). Multiple concurrent sessions per peer identity key are supported — the most recently updated session is returned when looking up by identity key.

Matches the ts-sdk SessionManager dual-index design.

Public Instance Methods

add_session(session)

Adds a session to the manager. - @param session [PeerSession] - @raise [ArgumentError] if +session_nonce+ is blank

get_session(identifier)

Retrieves a session by session_nonce or peer_identity_key.

When the identifier is a session nonce, returns that exact session. When the identifier is a peer identity key, returns the most recently updated session for that peer. - @param identifier [String] - @return [PeerSession, nil]

initialize()

  • @return [SessionManager] a new instance of SessionManager

remove_session(session)

Removes a session from the manager. - @param session [PeerSession]

session?(identifier)

  • @param identifier [String] session nonce or identity key
  • @return [Boolean]

update_session(session)

Updates an existing session (removes old references and re-adds). - @param session [PeerSession]