Class: YubiOATH

Inherits:
Object
  • Object
show all
Defined in:
lib/yubioath.rb,
lib/yubioath/put.rb,
lib/yubioath/list.rb,
lib/yubioath/reset.rb,
lib/yubioath/types.rb,
lib/yubioath/delete.rb,
lib/yubioath/select.rb,
lib/yubioath/response.rb,
lib/yubioath/calculate.rb,
lib/yubioath/algorithms.rb,
lib/yubioath/calculate_all.rb

Defined Under Namespace

Classes: Calculate, CalculateAll, Delete, List, Put, Reset, Response, Select

Constant Summary collapse

AID =
[0xA0, 0x00, 0x00, 0x05, 0x27, 0x21, 0x01, 0x01]
TYPES =
{HOTP: 0x1, TOTP: 0x2}
ALGORITHMS =
{SHA1: 0x1, SHA256: 0x2}

Instance Method Summary collapse

Constructor Details

#initialize(card) ⇒ YubiOATH

Returns a new instance of YubiOATH.



12
13
14
15
# File 'lib/yubioath.rb', line 12

def initialize(card)
  @card = card
  Select.new(@card).call(aid: AID)
end

Instance Method Details

#calculate(name:, timestamp:) ⇒ Object



17
18
19
# File 'lib/yubioath.rb', line 17

def calculate(name:, timestamp:)
  Calculate.new(@card).call(name: name, timestamp: timestamp)
end

#calculate_all(timestamp:) ⇒ Object



21
22
23
# File 'lib/yubioath.rb', line 21

def calculate_all(timestamp:)
  CalculateAll.new(@card).call(timestamp: timestamp)
end

#delete(name:) ⇒ Object



25
26
27
# File 'lib/yubioath.rb', line 25

def delete(name:)
  Delete.new(@card).call(name: name)
end

#listObject



29
30
31
# File 'lib/yubioath.rb', line 29

def list
  List.new(@card).call
end

#put(name:, secret:, algorithm: :SHA256, type: :TOTP, digits: 6) ⇒ Object



33
34
35
# File 'lib/yubioath.rb', line 33

def put(name:, secret:, algorithm: :SHA256, type: :TOTP, digits: 6)
  Put.new(@card).call(name: name, secret: secret, algorithm: algorithm, type: type, digits: digits)
end

#resetObject



37
38
39
# File 'lib/yubioath.rb', line 37

def reset
  Reset.new(@card).call
end