Class: Trailblazer::Pro::Session

Inherits:
Struct
  • Object
show all
Defined in:
lib/trailblazer/pro/session.rb

Overview

DISCUSS: do we want #id_token here explicitely? Data structure to hold all data values necessary to keep an authenticated session with Firebase.

Defined Under Namespace

Classes: Uninitialized

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key

Returns:

  • (Object)

    the current value of api_key



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def api_key
  @api_key
end

#expires_atObject

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def expires_at
  @expires_at
end

#firebase_refresh_urlObject

Returns the value of attribute firebase_refresh_url

Returns:

  • (Object)

    the current value of firebase_refresh_url



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def firebase_refresh_url
  @firebase_refresh_url
end

#firebase_signin_urlObject

Returns the value of attribute firebase_signin_url

Returns:

  • (Object)

    the current value of firebase_signin_url



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def 
  @firebase_signin_url
end

#firebase_upload_urlObject

Returns the value of attribute firebase_upload_url

Returns:

  • (Object)

    the current value of firebase_upload_url



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def firebase_upload_url
  @firebase_upload_url
end

#firestore_fields_templateObject

Returns the value of attribute firestore_fields_template

Returns:

  • (Object)

    the current value of firestore_fields_template



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def firestore_fields_template
  @firestore_fields_template
end

#id_tokenObject

Returns the value of attribute id_token

Returns:

  • (Object)

    the current value of id_token



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def id_token
  @id_token
end

#jwt_token_expObject

Returns the value of attribute jwt_token_exp

Returns:

  • (Object)

    the current value of jwt_token_exp



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def jwt_token_exp
  @jwt_token_exp
end

#refresh_tokenObject

Returns the value of attribute refresh_token

Returns:

  • (Object)

    the current value of refresh_token



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def refresh_token
  @refresh_token
end

#sessionObject

Returns the value of attribute session.



8
9
10
# File 'lib/trailblazer/pro/session.rb', line 8

def session
  @session
end

#trace_guardsObject

Returns the value of attribute trace_guards.



9
10
11
# File 'lib/trailblazer/pro/session.rb', line 9

def trace_guards
  @trace_guards
end

#trailblazer_pro_hostObject

Returns the value of attribute trailblazer_pro_host

Returns:

  • (Object)

    the current value of trailblazer_pro_host



6
7
8
# File 'lib/trailblazer/pro/session.rb', line 6

def trailblazer_pro_host
  @trailblazer_pro_host
end

#wtf_present_optionsObject

Returns the value of attribute wtf_present_options.



7
8
9
# File 'lib/trailblazer/pro/session.rb', line 7

def wtf_present_options
  @wtf_present_options
end

Class Method Details

.deserialize(json) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/trailblazer/pro/session.rb', line 24

def self.deserialize(json)
  data = JSON.parse(json)

  options = data.key?("jwt_token_exp") ? {expires_at: Trace.parse_exp(data["jwt_token_exp"])} : {}

  data
    .merge(options) # TODO: use representer
    .collect { |k, v| [k.to_sym, v] }
    .to_h
end

.serialize(session) ⇒ Object



17
18
19
20
21
22
# File 'lib/trailblazer/pro/session.rb', line 17

def self.serialize(session)
  attributes = session.to_h
  attributes = attributes.slice(*(attributes.keys - [:expires_at]))

  JSON.dump(attributes)
end