Module: Lich::Common::Authentication::LaunchResult
- Defined in:
- documented/common/authentication/launch_result.rb
Overview
Normalizes the launch-result hash returned by a single-character authentication (EAccess's non-legacy .auth, WebLogin's .auth) to one shared shape, so Authenticator and downstream consumers (LaunchData, session_launcher) don't need to know which provider produced it.
Deliberately a plain Hash, not a Struct/value class -- callers
(LaunchData.prepare) already consume it duck-typed as
auth_data.map { |k, v| ... }, and EAccess's legacy multi-game
enumeration mode returns a wholly different shape (an Array of
per-character hashes) that this module does not apply to.
Defined Under Namespace
Classes: MissingLaunchDataError
Constant Summary collapse
- REQUIRED_KEYS =
KEY is the one field both providers always have: EAccess gets it from every successful L response (even the generator path, which can omit GAMEHOST/GAMEPORT -- see eaccess_spec.rb's generator tests), and WebLogin gets it from the final redirect's query string. GAMEHOST/GAMEPORT are correspondingly NOT required here.
%w[key].freeze
Class Method Summary collapse
-
.normalize(raw) ⇒ Hash
The same data with lowercase string keys, frozen.
Class Method Details
.normalize(raw) ⇒ Hash
Returns the same data with lowercase string keys, frozen.
42 43 44 45 46 47 48 49 |
# File 'documented/common/authentication/launch_result.rb', line 42 def self.normalize(raw) normalized = raw.each_with_object({}) { |(k, v), h| h[k.to_s.downcase] = v } missing = REQUIRED_KEYS.select { |key| normalized[key].to_s.empty? } raise MissingLaunchDataError, missing unless missing.empty? normalized.freeze end |