pws-otp 0.9.0

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88a3c92413f95df3d2991139060e76ebe729d6a6
4
+ data.tar.gz: '0889b8355c7ddb700995b0ddfb9778d188b0cb7e'
5
+ SHA512:
6
+ metadata.gz: 5745beff84abf4e3a900284a07869a3bac1535321ec1a599dcb2004eef1916c8185a6b9cdfb60939e025aabcdcc49698771b0651cdcb92f05ce16b257eca8ff8
7
+ data.tar.gz: 53860bcbfd006d3ae0ee73f99f8cc687c601b406b26a880a776a7f0b4ece9cce2c5ab5bf97eea99167baac159f76fbcd718d51b1dc6d6ab6491a1ac9f7992a6a
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ /pkg
@@ -0,0 +1,22 @@
1
+ sudo: false
2
+ language: ruby
3
+
4
+ rvm:
5
+ - ruby-head
6
+ - 2.4.1
7
+ - 2.3.3
8
+ - 2.2
9
+ - 2.1
10
+ - 2.0
11
+ - jruby-head
12
+ - jruby-9.1.8.0
13
+
14
+ cache:
15
+ - bundler
16
+
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: jruby-head
20
+ - rvm: ruby-head
21
+ - rvm: 2.0
22
+ # fast_finish: true
@@ -0,0 +1,6 @@
1
+ ## CHANGELOG
2
+
3
+ ### 0.9.0
4
+
5
+ * Initial experimental release
6
+
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at opensource@janlelis.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
6
+ gem 'rake'
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2017 Jan Lelis, mail@janlelis.de
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # pws-otp [![[version]](https://badge.fury.io/rb/pws-otp.svg)](http://badge.fury.io/rb/pws-otp) [![[travis]](https://travis-ci.org/janlelis/pws-otp.svg)](https://travis-ci.org/janlelis/pws-otp)
2
+
3
+ Experimental OTP support for [pws](https://github.com/janlelis/pws) via [rotp](https://github.com/mdp/rotp).
4
+
5
+ ## Setup
6
+
7
+ ```
8
+ $ gem install pws-otp
9
+ ```
10
+
11
+
12
+ ## Usage
13
+
14
+ Get the current time-based OTP of a PWS entry (must be a Base32 seceret):
15
+
16
+ ```
17
+ $ pws-otp time [entry]
18
+ ```
19
+
20
+ ## MIT License
21
+
22
+ Copyright (C) 2017 Jan Lelis <http://janlelis.com>. Released under the MIT license.
@@ -0,0 +1,38 @@
1
+ # # #
2
+ # Get gemspec info
3
+
4
+ gemspec_file = Dir['*.gemspec'].first
5
+ gemspec = eval File.read(gemspec_file), binding, gemspec_file
6
+ info = "#{gemspec.name} | #{gemspec.version} | " \
7
+ "#{gemspec.runtime_dependencies.size} dependencies | " \
8
+ "#{gemspec.files.size} files"
9
+
10
+ # # #
11
+ # Gem build and install task
12
+
13
+ desc info
14
+ task :gem do
15
+ puts info + "\n\n"
16
+ print " "; sh "gem build #{gemspec_file}"
17
+ FileUtils.mkdir_p 'pkg'
18
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
19
+ puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
20
+ end
21
+
22
+ # # #
23
+ # Start an IRB session with the gem loaded
24
+
25
+ desc "#{gemspec.name} | IRB"
26
+ task :irb do
27
+ sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
28
+ end
29
+
30
+ # # #
31
+ # Run specs
32
+
33
+ desc "#{gemspec.name} | Spec"
34
+ task :spec do
35
+ sh "for file in spec/*_spec.rb; do ruby $file; done"
36
+ end
37
+ task default: :spec
38
+
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/pws/otp"
4
+
5
+ require "rationalist"
6
+
7
+ argv = Rationalist.parse
8
+
9
+ case argv[:_][0]
10
+ when "time"
11
+ action = :get_totp
12
+ else
13
+ raise ArgumentError, "no valid OTP action given"
14
+ end
15
+
16
+ arguments = argv[:_][1..-1]
17
+ # TODO Support same options as PWS
18
+ status = PWS.new({}).public_send(action, *arguments)
19
+ exit(status ? 0 : 2)
@@ -0,0 +1,39 @@
1
+ require "pws"
2
+ require "rotp"
3
+
4
+ require_relative "otp/version"
5
+
6
+ class PWS
7
+ module Otp
8
+ # Gets the TOTP secrect and copies current time based key to the clipboard.
9
+ # The second parameter is the time in seconds it stays there
10
+ def get_totp(key, seconds = @options[:seconds])
11
+ if real_key = @abbrevs[key]
12
+ secret = @data[real_key][:password]
13
+ password = ROTP::TOTP.new(secret).now
14
+ if seconds && seconds.to_i > 0
15
+ original_clipboard_content = Clipboard.paste
16
+ Clipboard.copy(password)
17
+ pa %[The password for #{real_key} is now available in your clipboard for #{seconds.to_i} second#{?s if seconds.to_i > 1}], :green
18
+ begin
19
+ sleep seconds.to_i
20
+ rescue Interrupt
21
+ Clipboard.copy original_clipboard_content
22
+ raise
23
+ end
24
+ Clipboard.copy original_clipboard_content
25
+ return true
26
+ else
27
+ Clipboard.copy(password)
28
+ pa %[The password for #{real_key} has been copied to your clipboard], :green
29
+ return true
30
+ end
31
+ else
32
+ pa %[No password found for #{key}!], :red
33
+ return false
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ PWS.include(PWS::Otp)
@@ -0,0 +1,6 @@
1
+ class PWS
2
+ module Otp
3
+ VERSION = "0.9.0".freeze
4
+ end
5
+ end
6
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + "/lib/pws/otp/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "pws-otp"
7
+ gem.version = PWS::Otp::VERSION
8
+ gem.summary = "OTP support for PWS"
9
+ gem.description = "Experimental OTP support for PWS"
10
+ gem.authors = ["Jan Lelis"]
11
+ gem.email = ["mail@janlelis.de"]
12
+ gem.homepage = "https://github.com/janlelis/pws-otp"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "pws", "~> 1.0"
21
+ gem.add_dependency "rotp", "~> 3.3"
22
+ gem.add_dependency "rationalist", "~> 2.0"
23
+
24
+ gem.required_ruby_version = "~> 2.1"
25
+ end
@@ -0,0 +1,9 @@
1
+ require_relative "../lib/pws/otp"
2
+ require "minitest/autorun"
3
+
4
+ describe PWS::Otp do
5
+ it "works" do
6
+ assert_equal true, false
7
+ end
8
+ end
9
+
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pws-otp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pws
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rotp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rationalist
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ description: Experimental OTP support for PWS
56
+ email:
57
+ - mail@janlelis.de
58
+ executables:
59
+ - pws-otp
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - MIT-LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/pws-otp
73
+ - lib/pws/otp.rb
74
+ - lib/pws/otp/version.rb
75
+ - pws-otp.gemspec
76
+ - spec/pws_otp_spec.rb
77
+ homepage: https://github.com/janlelis/pws-otp
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.6.11
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: OTP support for PWS
101
+ test_files:
102
+ - spec/pws_otp_spec.rb