Class: Clarion::Registrator

Inherits:
Object
  • Object
show all
Defined in:
lib/clarion/registrator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(u2f, counter) ⇒ Registrator

Returns a new instance of Registrator.



5
6
7
8
# File 'lib/clarion/registrator.rb', line 5

def initialize(u2f, counter)
  @u2f = u2f
  @counter = counter
end

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter.



10
11
12
# File 'lib/clarion/registrator.rb', line 10

def counter
  @counter
end

#u2fObject (readonly)

Returns the value of attribute u2f.



10
11
12
# File 'lib/clarion/registrator.rb', line 10

def u2f
  @u2f
end

Instance Method Details

#register!(challenges, response_json) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/clarion/registrator.rb', line 16

def register!(challenges, response_json)
  response = U2F::RegisterResponse.load_from_json(response_json)
  reg = u2f.register!(challenges, response)
  key = Key.new(handle: reg.key_handle, public_key: reg.public_key, counter: reg.counter)
  if counter
    counter.store(key)
  end
  key
end

#requestObject



12
13
14
# File 'lib/clarion/registrator.rb', line 12

def request
  [u2f.app_id, u2f.registration_requests]
end