Module: Trailblazer::Pro::Trace
- Defined in:
- lib/trailblazer/pro/trace/wtf.rb,
lib/trailblazer/pro/trace/store.rb,
lib/trailblazer/pro/trace/signin.rb,
lib/trailblazer/pro/trace/refresh.rb,
lib/trailblazer/pro/trace/decision.rb
Defined Under Namespace
Modules: Wtf
Classes: Decision, Refresh, Signin, Store
Class Method Summary
collapse
Class Method Details
.parse_exp(exp) ⇒ Object
20
21
22
|
# File 'lib/trailblazer/pro/trace/signin.rb', line 20
def self.parse_exp(exp)
DateTime.strptime(exp.to_s, "%s")
end
|
.parse_expires_at(ctx, jwt_token_exp:) ⇒ Object
16
17
18
|
# File 'lib/trailblazer/pro/trace/signin.rb', line 16
def self.parse_expires_at(ctx, jwt_token_exp:, **)
ctx[:expires_at] = parse_exp(jwt_token_exp)
end
|
.parse_jwt_token(ctx, id_token:) ⇒ Object
9
10
11
12
13
14
|
# File 'lib/trailblazer/pro/trace/signin.rb', line 9
def self.parse_jwt_token(ctx, id_token:, **)
token, _ = JWT.decode(id_token, nil, false, algorithm: "RS256")
ctx[:jwt_token_exp] = token["exp"]
end
|
.parse_response(ctx, response:) ⇒ Object
3
4
5
|
# File 'lib/trailblazer/pro/trace/signin.rb', line 3
def self.parse_response(ctx, response:, **)
ctx[:parsed_response] = JSON.parse(response.body)
end
|
.valid?(ctx, now:, expires_at:) ⇒ Boolean
24
25
26
27
28
29
|
# File 'lib/trailblazer/pro/trace/signin.rb', line 24
def self.valid?(ctx, now:, expires_at:, **)
puts "id_token expires at #{expires_at}, that is in #{((expires_at - now) * 24 * 60 * 60).to_i} seconds"
now < expires_at
end
|