authentic 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a0405bf6ab9d3d2032221c0bd437cc0613e2887
4
- data.tar.gz: 10fb91b9d22b3ed865dc78cf873c8ca17f30828f
3
+ metadata.gz: 8a5638eac32ad5d3c4da52d99a8c25ca5c2bdca5
4
+ data.tar.gz: ca509f3b357a2d5a8cdffa593c6721f45adb72cf
5
5
  SHA512:
6
- metadata.gz: d1f2c01f5e7445e1463e422bbea71f10d53ea7b8e5093b68c554609732462fec027baa0310ed07343edab89fe413ac4e7c02004fef16af5bcec68542a252f47c
7
- data.tar.gz: 1ddb1a3ebc93f0f8093c64a6c7cd17754fa68b1b9fb5c1a5a71654e43094f6f01f94cf91f3c42ae941b36192de6f6e9dc38a3c8679f17729e032312749210238
6
+ metadata.gz: 17d8c8a27bb04f8c36cfdd4adbbffcfe4d797ceb3ac4581fcbcca60a7157629024f6b72ecdd890aff20e25f7458a2b291da2ab818c5ae7d44d3d10c21aa365d0
7
+ data.tar.gz: 29649b4fdb4fe73a9193bd8a14d0b17956a886a81db9275854c480212402c7550d1c608455da30134191e16b32c879ec6de2ef4db9807608d6b7490bbe49aa51
data/README.md CHANGED
@@ -47,7 +47,7 @@ only be displayed the first time you setup TFA for the service.
47
47
  Once you have your TFA key in hand, adding it to `authentic` is as simple as:
48
48
 
49
49
  ```shell
50
- $ authentic add MyService hedere
50
+ $ authentic add MyService qwdrft6789jkh
51
51
  ✓ Service MyService added to keychain
52
52
  ```
53
53
 
data/bin/authentic CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require 'authentic'
4
4
 
5
+ trap("INT") { exit }
5
6
  Authentic::CLI.start
data/lib/authentic.rb CHANGED
@@ -11,14 +11,14 @@ module Authentic
11
11
  package_name "Authentic"
12
12
  default_task :generate
13
13
 
14
- desc "add NAME SECRET_KEY [LABEL]", "Add a new TOTP key"
15
- def add(name, secret_key, label = nil)
14
+ desc "add NAME SECRET_KEY [SERVICE]", "Add a new TOTP key"
15
+ def add(name, secret_key, service = nil)
16
16
  params = {
17
- service: "authentic gem",
18
- password: secret_key,
17
+ label: "authentic gem",
19
18
  account: name,
19
+ service: service || name,
20
+ password: secret_key,
20
21
  }
21
- params[:comment] = label if label
22
22
 
23
23
  begin
24
24
  item = Keychain.generic_passwords.create(params)
@@ -59,27 +59,39 @@ module Authentic
59
59
 
60
60
  desc "generate", "Generate TOTP codes"
61
61
  option 'skip-copy', default: false, type: :boolean, aliases: '-s'
62
+ option 'qr-codes', default: false, type: :boolean, aliases: '-qr'
62
63
  def generate
63
64
  now = Time.now
64
65
  keys = Keychain
65
66
  .generic_passwords
66
- .where(service: "authentic gem")
67
+ .where(label: "authentic gem")
67
68
  .all.map do |key|
68
- totp = ROTP::TOTP.new(key.password.gsub(/=*$/, ''))
69
+ secret = key.password.gsub(/=*$/, '')
70
+ totp = ROTP::TOTP.new(secret)
69
71
  OpenStruct.new(
70
- code: totp.at(now),
71
- name: key.attributes[:account],
72
- label: key.attributes[:comment],
73
- remain: now.utc.to_i % totp.interval
72
+ secret: secret,
73
+ code: totp.at(now),
74
+ name: key.attributes[:account],
75
+ service: key.attributes[:service],
76
+ remain: now.utc.to_i % totp.interval
74
77
  )
75
- end
78
+ end.sort_by { |k| [k.service, k.name] }
79
+
80
+ if options['qr-codes']
81
+ keys.each do |key|
82
+ puts "#{key.service} - #{key.name}\n"
83
+ puts `qrencode 'otpauth://totp/#{key.name}?issuer=#{key.service}&secret=#{key.secret}' -s 5 -o - | ~/.iterm2/imgcat`
84
+ end
85
+ return
86
+ end
76
87
 
77
88
  table = keys.each_with_index.map do |key, idx|
78
89
  number = (idx + 1).to_s.rjust(keys.size.to_s.size, ' ')
90
+ service_prefix = "#{key.service} - " if key.service && key.service != key.name
79
91
  [
80
92
  number.colorize(:red),
81
93
  key.code.colorize(:green),
82
- "#{key.name} #{(" (#{key.label})" if key.label)}",
94
+ "#{service_prefix}#{key.name}",
83
95
  CLOCKS[7 * (key.remain / 7)].colorize(:blue)
84
96
  ]
85
97
  end
@@ -1,3 +1,3 @@
1
1
  module Authentic
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authentic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2017-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize