otpui 0.2.0 → 0.3.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: 4ae3b2332f1619882ca28125ed1d19a4fb740ea6
4
- data.tar.gz: 6f954bb6a0513a490901e9d06a5104a19d7dab53
3
+ metadata.gz: bdcf392550efcfff95326e2f3921c686713b2115
4
+ data.tar.gz: 40ebd3509665941817a704087b9d608d9f92e0a2
5
5
  SHA512:
6
- metadata.gz: c4028722f22e3e5f14e2e418d0c0d3b9f5b87ed7016537a8af067f2f23998738dea8d4d23d45fa0ac94fb488f10bcca652fc490c94b39af465d9890537f36270
7
- data.tar.gz: 3a46b5adfe89a66111bf9177828bf2ca3b89b49d990a58054455afd33a7381a95ff45c665cdfd3714c6b058c32b34d2604b65644c4a2ce3d84142b8d83ba06a4
6
+ metadata.gz: 64789f354e9e9c2cd0f0383357913c86aecb784c7448c707fd8ef0a8d77876f677e2d00ba9e94ced675313adf3617af397b0a56bb7de56cf9a877506a2bdbb41
7
+ data.tar.gz: da44d46d1b3de62184dbc818720f993868c7cc23efd4c832a984eabb606479d952792e03a1e3bce3deb082bcd7c09453700d6812a59ee3cf7481bcd1fbf7fed3
data/README.md CHANGED
@@ -8,7 +8,7 @@ Basic GTK app to display and copy OTP on Linux
8
8
  - [x] Import secrets directly
9
9
  - [x] Copy in clipboard on double click
10
10
  - [ ] Delete a OTP
11
- - [ ] Show timer
11
+ - [x] Show timer
12
12
  - [ ] Stop stealing Google Authenticator logo
13
13
  - [ ] Be pretty
14
14
 
@@ -42,6 +42,7 @@ module Otpui
42
42
  dialog = Gtk::FileChooserDialog.new(
43
43
  title: "Gtk::FileChooser sample",
44
44
  action: Gtk::FileChooserAction::OPEN,
45
+ parent: @main_window,
45
46
  buttons: [
46
47
  [Gtk::Stock::OPEN, Gtk::ResponseType::ACCEPT],
47
48
  [Gtk::Stock::CANCEL, Gtk::ResponseType::CANCEL]
@@ -82,12 +83,14 @@ module Otpui
82
83
  @about_window.version = Otpui::VERSION
83
84
  @about_window.logo = logo
84
85
 
86
+ @main_window = @builder["main_window"]
87
+
85
88
  otp_list = OtpList.new(@builder)
86
89
  otp_list.run
87
90
 
88
91
  connect_signals
89
92
 
90
- @builder["main_window"].show_all
93
+ @main_window.show_all
91
94
 
92
95
  Gtk.main
93
96
  end
@@ -3,10 +3,12 @@ module Otpui
3
3
  def initialize(builder)
4
4
  @otps = Settings.load.secrets
5
5
  @model = Gtk::ListStore.new(String, String)
6
+ @progress_bar = builder["totp_timeout_progress_bar"]
6
7
 
7
- renderer = Gtk::CellRendererText.new
8
- column_name = Gtk::TreeViewColumn.new("Issuer", renderer, { text: 0 })
9
- column_secret = Gtk::TreeViewColumn.new("Secret", renderer, { text: 1 })
8
+ text_renderer = Gtk::CellRendererText.new
9
+
10
+ column_name = Gtk::TreeViewColumn.new("Issuer", text_renderer, { text: 0 })
11
+ column_secret = Gtk::TreeViewColumn.new("Secret", text_renderer, { text: 1 })
10
12
  treeview = Gtk::TreeView.new(@model)
11
13
 
12
14
  treeview.append_column(column_name)
@@ -26,11 +28,29 @@ module Otpui
26
28
  i
27
29
  end
28
30
 
31
+ def get_current_second(totp, otp)
32
+ future_seconds = 0.0
33
+ while totp.verify(otp, Time.now + future_seconds)
34
+ future_seconds += 1
35
+ end
36
+ future_seconds
37
+ end
38
+
39
+ def get_fraction_progress(totp, otp)
40
+ get_current_second(totp, otp) / 30
41
+ end
42
+
43
+ def update_row(iter, secret = nil, issuer = nil)
44
+ secret = @otps.fetch iter[0] unless secret
45
+ iter[0] = issuer if issuer
46
+
47
+ totp = ROTP::TOTP.new(secret)
48
+ iter[1] = totp.now.to_s
49
+ end
50
+
29
51
  def refresh_values
30
52
  @model.each do |_model, path, iter|
31
- secret = @otps.fetch iter[0]
32
- totp = ROTP::TOTP.new(secret)
33
- iter[1] = totp.now.to_s
53
+ update_row iter
34
54
  end
35
55
  end
36
56
 
@@ -38,14 +58,18 @@ module Otpui
38
58
  @model.clear
39
59
  @otps.each do |issuer, secret|
40
60
  iter = @model.append
41
- totp = ROTP::TOTP.new(secret)
42
- iter[0] = issuer
43
- iter[1] = totp.now.to_s
61
+ update_row iter, secret, issuer
44
62
  end
45
63
  end
46
64
 
65
+ def refresh_progress_bar
66
+ totp = ROTP::TOTP.new("progress32secret3232")
67
+ @progress_bar.fraction = get_fraction_progress(totp, totp.now.to_s)
68
+ end
69
+
47
70
  def run
48
71
  GLib::Timeout.add(1000) do
72
+ refresh_progress_bar
49
73
  list_size == @otps.size ?
50
74
  refresh_values :
51
75
  refresh_all
@@ -1,3 +1,3 @@
1
1
  module Otpui
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -45,7 +45,7 @@
45
45
  </object>
46
46
  <object class="GtkApplicationWindow" id="main_window">
47
47
  <property name="can_focus">False</property>
48
- <property name="default_width">400</property>
48
+ <property name="default_width">200</property>
49
49
  <property name="default_height">500</property>
50
50
  <signal name="destroy" handler="on_main_window_destroy" swapped="no"/>
51
51
  <child>
@@ -188,6 +188,17 @@
188
188
  <property name="position">0</property>
189
189
  </packing>
190
190
  </child>
191
+ <child>
192
+ <object class="GtkProgressBar" id="totp_timeout_progress_bar">
193
+ <property name="visible">True</property>
194
+ <property name="can_focus">False</property>
195
+ </object>
196
+ <packing>
197
+ <property name="expand">False</property>
198
+ <property name="fill">True</property>
199
+ <property name="position">1</property>
200
+ </packing>
201
+ </child>
191
202
  <child>
192
203
  <object class="GtkScrolledWindow" id="scrolled_otps_win">
193
204
  <property name="visible">True</property>
@@ -200,7 +211,7 @@
200
211
  <packing>
201
212
  <property name="expand">True</property>
202
213
  <property name="fill">True</property>
203
- <property name="position">1</property>
214
+ <property name="position">2</property>
204
215
  </packing>
205
216
  </child>
206
217
  </object>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: otpui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Vaillant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.4.8
188
+ rubygems_version: 2.6.8
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: One Time Password Ui