Sha256: fc690af740a4ecb75e1340e7b3ebe5f3491b274109743df9441e995ea62e819b
Contents?: true
Size: 656 Bytes
Versions: 3
Compression:
Stored size: 656 Bytes
Contents
module TFA class TotpCommand def initialize(storage) @storage = storage end def run(arguments) return password_for(secret_for(arguments.first)) if valid?(arguments) all_passwords end private def password_for(secret) ::ROTP::TOTP.new(secret).now end def all_passwords secrets = @storage.all_secrets secrets.each do |hash| hash[hash.keys.first] = password_for(hash[hash.keys.first]) end secrets end def secret_for(key) @storage.secret_for(key) end def valid?(arguments) arguments.any? && secret_for(arguments.first) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tfa-0.0.8 | lib/tfa/totp_command.rb |
tfa-0.0.7 | lib/tfa/totp_command.rb |
tfa-0.0.6 | lib/tfa/totp_command.rb |