Class: OmniAuth::Strategies::Blockstack

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/blockstack.rb

Defined Under Namespace

Classes: ClaimInvalid

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/omniauth/strategies/blockstack.rb', line 50

def callback_phase
  auth_response = request.params['authResponse']

  ::Blockstack.api = options.api
  ::Blockstack.leeway = options.leeway
  ::Blockstack.valid_within = options.valid_within
  @decoded_token = ::Blockstack.verify_auth_response auth_response
  puts "decoded_token: #{decoded_token}"
  super

rescue ::Blockstack::InvalidAuthResponse => error
  fail! :invalid_auth_response, error
end

#decoded_tokenObject



22
23
24
# File 'lib/omniauth/strategies/blockstack.rb', line 22

def decoded_token
  @decoded_token
end

#request_phaseObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/omniauth/strategies/blockstack.rb', line 26

def request_phase
  blockstack_js = File.open(File.join(File.dirname(__FILE__), "blockstack.js"), "rb").read

  auth_request_js = File.open(File.join(File.dirname(__FILE__), "auth-request.js"), "rb").read

  header_info = "<script>#{blockstack_js}</script>"
  app_data_js = <<~JAVASCRIPT
  var signingKey = null
  var appManifest = {
  name: "#{options.app_name}",
  start_url: "#{callback_url}",
  description: "#{options.app_description}",
  icons: #{options.app_icons.to_json}
  }
  JAVASCRIPT

  header_info << "<script>#{app_data_js}</script>"
  header_info << "<script>#{auth_request_js}</script>"
  form = OmniAuth::Form.new(:title => "Blockstack Auth Request Generator",
  :header_info => header_info,
  :url => callback_path)
  form.to_response
end