Liking cljdoc? Tell your friends :D

boundary.user.core.session

Functional Core - Pure session business logic - Minimal working version

Functional Core - Pure session business logic - Minimal working version
raw docstring

analyze-session-durationclj

(analyze-session-duration session now)

Calculate session duration in hours from creation to last access.

Calculate session duration in hours from creation to last access.
sourceraw docstring

calculate-session-expiryclj

(calculate-session-expiry created-at remember-me?)
(calculate-session-expiry created-at remember-me? custom-hours)

Calculate session expiry instant. Remember-me sessions last 30 days, otherwise 24h.

Calculate session expiry instant. Remember-me sessions last 30 days, otherwise 24h.
sourceraw docstring

calculate-session-risk-scoreclj

(calculate-session-risk-score session previous-sessions)

Calculate a 0.0-1.0 risk score based on IP changes and concurrent sessions.

Calculate a 0.0-1.0 risk score based on IP changes and concurrent sessions.
sourceraw docstring

calculate-user-session-statsclj

(calculate-user-session-stats sessions user-id)

Compute active/inactive session counts for a given user-id.

Compute active/inactive session counts for a given user-id.
sourceraw docstring

detect-suspicious-activity?clj

(detect-suspicious-activity? session previous-sessions)

Detect suspicious patterns (IP change, concurrent sessions) between current and previous sessions.

Detect suspicious patterns (IP change, concurrent sessions) between current and previous sessions.
sourceraw docstring

extract-device-infoclj

(extract-device-info user-agent ip-address)

Parse user-agent and ip-address into a device-info map with :device-type.

Parse user-agent and ip-address into a device-info map with :device-type.
sourceraw docstring

filter-sessions-for-cleanupclj

(filter-sessions-for-cleanup sessions current-time)

Return sessions that have been expired past the cleanup grace period.

Return sessions that have been expired past the cleanup grace period.
sourceraw docstring

generate-session-tokenclj

(generate-session-token timestamp-ms nonce)

Build a deterministic session token from a timestamp and nonce.

Build a deterministic session token from a timestamp and nonce.
sourceraw docstring

group-sessions-by-device-typeclj

(group-sessions-by-device-type sessions)

Group sessions into :mobile, :desktop, or :other based on user-agent.

Group sessions into :mobile, :desktop, or :other based on user-agent.
sourceraw docstring

is-same-device?clj

(is-same-device? device1 device2)

Check if two device-info maps represent the same device (same IP and similar user-agent).

Check if two device-info maps represent the same device (same IP and similar user-agent).
sourceraw docstring

is-session-valid?clj

(is-session-valid? session current-time)

Check if session is valid: not nil, not revoked, and not expired.

Check if session is valid: not nil, not revoked, and not expired.
sourceraw docstring

mark-session-for-cleanupclj

(mark-session-for-cleanup session current-time)

Mark session as revoked by setting :revoked-at to current time.

Mark session as revoked by setting :revoked-at to current time.
sourceraw docstring

prepare-session-for-access-updateclj

(prepare-session-for-access-update session current-time)

Pure function: Prepare session for access time update.

Args: session: Current session entity current-time: Current timestamp

Returns: Session entity with updated access time

Pure - data transformation only.

Pure function: Prepare session for access time update.

Args:
  session: Current session entity
  current-time: Current timestamp
  
Returns:
  Session entity with updated access time
  
Pure - data transformation only.
sourceraw docstring

prepare-session-for-creationclj

(prepare-session-for-creation session-data current-time session-id token)
(prepare-session-for-creation session-data
                              current-time
                              session-id
                              token
                              session-policy)

Assemble a complete session map from raw data, id, token, and timestamps.

Assemble a complete session map from raw data, id, token, and timestamps.
sourceraw docstring

prepare-session-for-invalidationclj

(prepare-session-for-invalidation session current-time)

Pure function: Prepare session for invalidation.

Args: session: Current session entity current-time: Current timestamp

Returns: Session entity marked as revoked

Pure - data transformation only.

Pure function: Prepare session for invalidation.

Args:
  session: Current session entity
  current-time: Current timestamp
  
Returns:
  Session entity marked as revoked
  
Pure - data transformation only.
sourceraw docstring

should-cleanup-session?clj

(should-cleanup-session? session current-time cleanup-policy)

Return true if session has been expired longer than the grace period.

Return true if session has been expired longer than the grace period.
sourceraw docstring

should-extend-session?clj

(should-extend-session? session current-time extension-policy)

Return true if session is close enough to expiry to warrant extension.

Return true if session is close enough to expiry to warrant extension.
sourceraw docstring

should-require-additional-verification?clj

(should-require-additional-verification? session previous-sessions)

Return true if session risk score exceeds the verification threshold (0.5).

Return true if session risk score exceeds the verification threshold (0.5).
sourceraw docstring

should-update-access-time?clj

(should-update-access-time? session current-time update-policy)

Pure function: Determine if session access time should be updated.

Args: session: Current session entity current-time: Current timestamp update-policy: Map with access update configuration

Returns: Boolean indicating if access time should be updated

Pure - business rule evaluation based on policy and time difference.

Pure function: Determine if session access time should be updated.

Args:
  session: Current session entity
  current-time: Current timestamp
  update-policy: Map with access update configuration
  
Returns:
  Boolean indicating if access time should be updated
  
Pure - business rule evaluation based on policy and time difference.
sourceraw docstring

update-session-accessclj

(update-session-access session current-time)

Update last-accessed-at and optionally extend expiry if near threshold.

Update last-accessed-at and optionally extend expiry if near threshold.
sourceraw docstring

validate-session-creation-requestclj

(validate-session-creation-request session-data)

Validate that session-data has the required :user-id key.

Validate that session-data has the required :user-id key.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close