talcotp 0.2 → 0.3
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 +4 -4
- data/README.md +52 -0
- data/bin/talcotp +14 -1
- data/lib/talcotp.rb +20 -9
- data/talcotp.gemspec +2 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fbdf0b9f10b5dd304a59f63c293eab2248b7364cc472f82254738c2bd4f5e6e
|
4
|
+
data.tar.gz: 214578d09106e83558727c5fefc3cfbbf4dd71fcf0b87c8ac6e6c17a273b1cca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e9b6c02be734108d94ad6f4422d18d2b7945f967ff9623c536ed50dea25bd3c8cf0a64bf33ba13f4d84ce68ecd12eccbd1d17e73e85c6fb34b01a88f8bf40d3
|
7
|
+
data.tar.gz: d650ff4da39feed9eb24f2028103e010a44facc4611f6ada9a5e203b047c82fdf1322025437a5f3ca358d6cc8433126f3116c6e45dd945cd002fcf241a0d55cf
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# TalcOTP
|
2
|
+
|
3
|
+
An otp password generator using [rotp](https://github.com/mdp/rotp)
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Run this command to print all the current codes:
|
8
|
+
|
9
|
+
```
|
10
|
+
talcotp /path/to/otp_file
|
11
|
+
```
|
12
|
+
|
13
|
+
Where the `otp_file` is of the format:
|
14
|
+
|
15
|
+
```
|
16
|
+
[
|
17
|
+
{
|
18
|
+
"secret":"JBSWY3DPEHPK3PXP",
|
19
|
+
"label":"test_label",
|
20
|
+
"period":30,
|
21
|
+
"digits":6,
|
22
|
+
"algorithm":"SHA1"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"secret":"wrn3pqx5uqxqvnqr",
|
26
|
+
"label":"test_label_2",
|
27
|
+
"period":40,
|
28
|
+
"digits":7,
|
29
|
+
"algorithm":"SHA256"
|
30
|
+
}
|
31
|
+
]
|
32
|
+
```
|
33
|
+
|
34
|
+
You can also run the command passing in the name of the account in order for it to copy the code to the clipboard:
|
35
|
+
|
36
|
+
```
|
37
|
+
talcotp /path/to/otp_file test_label
|
38
|
+
```
|
39
|
+
|
40
|
+
## Installation
|
41
|
+
|
42
|
+
```
|
43
|
+
gem install talcotp
|
44
|
+
```
|
45
|
+
|
46
|
+
## Building the gem from source
|
47
|
+
|
48
|
+
You can build from source with the following command:
|
49
|
+
|
50
|
+
```
|
51
|
+
gem build talcotp.gemspec
|
52
|
+
```
|
data/bin/talcotp
CHANGED
@@ -2,5 +2,18 @@
|
|
2
2
|
|
3
3
|
$: << File.expand_path('../../lib', __FILE__)
|
4
4
|
require "talcotp"
|
5
|
+
require "clipboard"
|
5
6
|
|
6
|
-
|
7
|
+
unless ARGV[0]
|
8
|
+
puts "NO!"
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
code_manager = TalcOTP.new(ARGV[0])
|
13
|
+
|
14
|
+
if (ARGV[1])
|
15
|
+
Clipboard.copy code_manager[ARGV[1]]
|
16
|
+
puts ARGV[1] + " code copied to clipboard"
|
17
|
+
else
|
18
|
+
puts code_manager.all_codes_string
|
19
|
+
end
|
data/lib/talcotp.rb
CHANGED
@@ -12,20 +12,31 @@ class TalcOTP
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def all_codes_string
|
16
16
|
output = ''
|
17
17
|
@accounts.each do |account|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
digest: account['algorithm']
|
22
|
-
}
|
23
|
-
auth_code = ROTP::TOTP.new(account['secret'], account_settings).now
|
24
|
-
|
25
|
-
output += "#{account['label']}: #{auth_code}\n"
|
18
|
+
account_auth_code = auth_code(account)
|
19
|
+
|
20
|
+
output += "#{account['label']}: #{account_auth_code}\n"
|
26
21
|
end
|
27
22
|
|
28
23
|
output
|
29
24
|
end
|
25
|
+
|
26
|
+
def [](account_name)
|
27
|
+
account = @accounts.find { |account| account["label"] == account_name }
|
28
|
+
return auth_code(account)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def auth_code(account)
|
34
|
+
account_settings = {
|
35
|
+
interval: account['period'],
|
36
|
+
digits: account['digits'],
|
37
|
+
digest: account['algorithm']
|
38
|
+
}
|
39
|
+
return ROTP::TOTP.new(account['secret'], account_settings).now
|
40
|
+
end
|
30
41
|
end
|
31
42
|
|
data/talcotp.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "talcotp"
|
3
|
-
s.version = 0.
|
3
|
+
s.version = 0.3
|
4
4
|
s.license = "MIT"
|
5
5
|
s.authors = ["Keeyan Nejad"]
|
6
6
|
s.email = ["keeyan@keeyan.xyz"]
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
|
14
14
|
s.add_dependency 'rotp', '~> 4.0'
|
15
|
+
s.add_dependency 'clipboard', '~> 1.3'
|
15
16
|
s.add_development_dependency 'rake', '~> 10.5'
|
16
17
|
s.add_development_dependency 'rspec', '~> 3.5'
|
17
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: talcotp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keeyan Nejad
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rotp
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: clipboard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,6 +75,7 @@ extensions: []
|
|
61
75
|
extra_rdoc_files: []
|
62
76
|
files:
|
63
77
|
- ".gitignore"
|
78
|
+
- README.md
|
64
79
|
- bin/talcotp
|
65
80
|
- lib/talcotp.rb
|
66
81
|
- talcotp.gemspec
|