onetime 0.5.1 → 0.7.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0220be9c2e382cae289a9c9f350a2ed9fc1541da377800216b0b06ff7e93671e
4
+ data.tar.gz: 6fe4dd6670c7ea344c4af9dff5826eca2d93abfe7910690d2fab465ff9310a98
5
+ SHA512:
6
+ metadata.gz: 7704b043afd1c6f65b80f9a5f37f57ce2190afdc58750c55f6d61a6a45c9910f5fc2a6057ad5864e38e4f83303898c117492de3d15d2b01536d776942ca0362e
7
+ data.tar.gz: a9765b7964903cf64e013472cb3a9bb151cd6a7557da14188a2ebb012bae43bfc9532523043345064c21f51c56c172bb3498589f871a72795b15e9a5a4c55ece
data/README.md CHANGED
@@ -1,101 +1,17 @@
1
- # One-Time Secret 0.5 #
1
+ # `onetime` compatibility package
2
2
 
3
- **Keep sensitive info out of your chat logs & email.**
3
+ The canonical RubyGem for the OnetimeSecret Ruby client is now
4
+ [`onetimesecret`](https://rubygems.org/gems/onetimesecret).
4
5
 
5
- ## Basic Usage ##
6
+ Update your Gemfile:
6
7
 
7
- Use `onetime` to share something you know (a secret phrase, a special link, etc) or to generate a secret (e.g. a temporary password).
8
+ ```ruby
9
+ gem "onetimesecret", "~> 0.7.0"
10
+ ```
8
11
 
9
- ### onetime share ###
12
+ The Ruby API remains under the `Onetime` namespace. Both
13
+ `require "onetimesecret"` and `require "onetime"` are supported by the
14
+ canonical package.
10
15
 
11
- You can pipe it:
12
-
13
- $ echo "I STILL WATCH NIGHT COURT." | onetime
14
- https://onetimesecret.com/secret/mc5o2649tva6885wvyspm0flobsasin
15
-
16
- You can type it:
17
-
18
- $ onetime
19
- Paste secret here (hit control-D to continue):
20
- I STILL WATCH NIGHT COURT.
21
- https://onetimesecret.com/secret/3djys3b7tridrcvbiprqjejz0c2g07x
22
-
23
- And you can read from a file:
24
-
25
- $ <path/2/file onetime
26
- https://onetimesecret.com/secret/8f8k3ajhax87ctln3h6y11nsb4vf0wq
27
-
28
- *Note that we don't use `cat` in that example! We don't want to provoke the [ire of Randal L. Schwartz](http://partmaps.org/era/unix/award.html).*
29
-
30
-
31
- ### onetime generate ###
32
-
33
- $ onetime generate
34
- Your secret: CttenFwzVpjs
35
- https://onetimesecret.com/secret/er5djg1wodsp5m32oyym489bnuhsfp6
36
-
37
-
38
- ### onetime get ###
39
-
40
- You can retrieve a secret too:
41
-
42
- $ onetime get er5djg1wodsp5m32oyym489bnuhsfp6
43
- [...SECRET...]
44
-
45
- The URI works too:
46
-
47
- $ onetime get https://onetimesecret.com/secret/er5djg1wodsp5m32oyym489bnuhsfp6
48
- [...SECRET...]
49
-
50
- ## Output Format ##
51
-
52
- `onetime` also supports YAML, JSON, and to a limited extent CSV outputs. Specify the format using the `-f ` global option:
53
-
54
- $ onetime -f yaml generate
55
- ---
56
- value: MhYcuge9VxtX
57
- metadata_key: 4j1122kpd6clemp80gpobu9xfxsp7zu
58
- secret_key: 8f8k3ajhax87ctln3h6y11nsb4vf0wq
59
- ttl: 172800
60
- passphrase_required: false
61
-
62
- ## Installation ###
63
-
64
- $ [sudo] gem install onetime
65
-
66
- However, in order to be sure the code you're installing hasn't been tampered with, it's recommended that you verify the signiture[http://docs.rubygems.org/read/chapter/21]. To do this, you need to add my public key as a trusted certificate (you only need to do this once):
67
-
68
- # Add the public key as a trusted certificate
69
- # (You only need to do this once)
70
- $ curl -O https://raw.github.com/onetimesecret/onetime-ruby/master/gem-public_cert.pem
71
- $ gem cert --add gem-public_cert.pem
72
-
73
- Then, when install the gem, do so with high security:
74
-
75
- $ gem install onetime -P HighSecurity
76
-
77
- If you don't add the public key, you'll see an error like "Couldn't verify data signature". If you're still having trouble let me know and I'll give you a hand.
78
-
79
- ## More Info ##
80
-
81
- * [API docs](https://onetimesecret.com/docs/api)
82
- * [Codes](https://github.com/onetimesecret/onetime-ruby)
83
- * [Rubgems](https://rubygems.org/gems/onetime)
84
- * [One-Time Secret](https://onetimesecret.com/)
85
-
86
- See also:
87
-
88
- $ onetime -h
89
- $ onetime show-commands
90
- $ onetime share -h
91
- $ onetime generate -h
92
-
93
- ## Thanks ##
94
-
95
- * Kyle Dawkins for the [perl lib](https://github.com/quile/onetime-perl)
96
- * Drew Carey for [tweeting about us](https://twitter.com/DrewFromTV/status/142730130689761280)
97
-
98
-
99
- ## License ##
100
-
101
- See LICENSE.txt
16
+ This package contains no implementation files. It depends on `onetimesecret`
17
+ so existing `onetime` users can transition without loading conflicting files.
metadata CHANGED
@@ -1,132 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onetime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Delano Mandelbaum
9
- autorequire:
10
8
  bindir: bin
11
- cert_chain:
12
- - !binary |-
13
- LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUROakNDQWg2Z0F3SUJB
14
- Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREJCTVE4d0RRWURWUVFEREFaa1pX
15
- eGgKYm04eEdUQVhCZ29Ka2lhSmsvSXNaQUVaRmdsemIyeDFkR2x2ZFhNeEV6
16
- QVJCZ29Ka2lhSmsvSXNaQUVaRmdOagpiMjB3SGhjTk1UTXdNakEyTVRFMU56
17
- UTFXaGNOTVRRd01qQTJNVEUxTnpRMVdqQkJNUTh3RFFZRFZRUUREQVprClpX
18
- eGhibTh4R1RBWEJnb0praWFKay9Jc1pBRVpGZ2x6YjJ4MWRHbHZkWE14RXpB
19
- UkJnb0praWFKay9Jc1pBRVoKRmdOamIyMHdnZ0VpTUEwR0NTcUdTSWIzRFFF
20
- QkFRVUFBNElCRHdBd2dnRUtBb0lCQVFEZzFoTXRsMFhzTXVVSwpBS1RnWVd2
21
- M2dqajd2dUVzRTJFalQrdnlCZzgvTHBxVlZ3WnppaWFlYkpUOUlaaVErc0NG
22
- cWJpYWtqMGI1M3BJCmhnMXlPYUJFbUg2L1cwTDdyd3pxYVJWOXNXMWVKczlK
23
- eEZZUUNuZDY3elVuemo4bm5SbE9qRytoaElHK1ZzaWoKbnBzR2J0MjhwZWZ1
24
- TlpKak81cTJjbEFsZlNuaUlJSGZJc1U3L1N0RVl1NkZVR09qbndyeVowcjV5
25
- SmxyOVJyRQpHcytxMERXOFFuWjlVcEFmdURGUVp1SXFlS1FGRkxFN25NbUNH
26
- YUErMEJOMW5MbDNmVkhOYkxIcTdBdms4K1orClp1dXZrZHNjYkhsTy9sKzN4
27
- Q05RNW5Vbkh3cTBBREFiTUxPbG1pWVl6cVhvV0xqbWVJNm1lL2Nsa3RKQ2ZO
28
- MlIKb1pHM1VRdnZBZ01CQUFHak9UQTNNQWtHQTFVZEV3UUNNQUF3SFFZRFZS
29
- ME9CQllFRk1TSk9FdEh6RTRsMGF6dgpNMEpLMGtLTlRvSzFNQXNHQTFVZER3
30
- UUVBd0lFc0RBTkJna3Foa2lHOXcwQkFRVUZBQU9DQVFFQXRPZEU3M3F4Ck9I
31
- MnlkaTlvVDJoUzVmOUcweTFaNzBUbHdoK1ZHRXh5Znh6VkU5WHdDK2lQcEp4
32
- TnJhaUhZZ0YvOS9va3k3WloKUjlxMC90Sm5ldWhBZW5aZGlRa1g3b2k0TzN2
33
- OXdSUzZZSG9XQnhNUEZLVlJMTlR6dlZKc2JtZnBDQWxwNS81ZwpwczR3UUZ5
34
- NW1pYkVsR1ZsT29iZi9naHFaMjVIUzlKNmtkMC9DL3J5MEFVdFRvZ3NMN1R4
35
- R3dUNGtiQ3g2M3ViCjN2eXdFRWhzSlV6ZmQ5N0dDQUJtdFFmUlRsZFgvajdG
36
- MXovNXdkOHAraGZkb3gxaWliZHM5WnRmYVpBM0t6S24Ka2NoV045QjZ6Zzly
37
- MVhNUThCTTJKejBYb1BhblBlMzU0K2xXd2pwa1JLYkZvdy9aYlFIY0NMQ3Ey
38
- NCtONmI2ZwpkZ0tmTkR6d2lEcHFDQT09Ci0tLS0tRU5EIENFUlRJRklDQVRF
39
- LS0tLS0K
40
- date: 2013-02-12 00:00:00.000000000 Z
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
41
11
  dependencies:
42
12
  - !ruby/object:Gem::Dependency
43
- name: drydock
13
+ name: onetimesecret
44
14
  requirement: !ruby/object:Gem::Requirement
45
- none: false
46
15
  requirements:
47
- - - ! '>='
16
+ - - "~>"
48
17
  - !ruby/object:Gem::Version
49
- version: 0.6.9
18
+ version: 0.7.0
50
19
  type: :runtime
51
20
  prerelease: false
52
21
  version_requirements: !ruby/object:Gem::Requirement
53
- none: false
54
22
  requirements:
55
- - - ! '>='
23
+ - - "~>"
56
24
  - !ruby/object:Gem::Version
57
- version: 0.6.9
25
+ version: 0.7.0
58
26
  - !ruby/object:Gem::Dependency
59
- name: httparty
27
+ name: rake
60
28
  requirement: !ruby/object:Gem::Requirement
61
- none: false
62
29
  requirements:
63
- - - ! '>='
30
+ - - "~>"
64
31
  - !ruby/object:Gem::Version
65
- version: 0.7.7
66
- type: :runtime
32
+ version: '13.0'
33
+ type: :development
67
34
  prerelease: false
68
35
  version_requirements: !ruby/object:Gem::Requirement
69
- none: false
70
36
  requirements:
71
- - - ! '>='
37
+ - - "~>"
72
38
  - !ruby/object:Gem::Version
73
- version: 0.7.7
74
- - !ruby/object:Gem::Dependency
75
- name: json
76
- requirement: !ruby/object:Gem::Requirement
77
- none: false
78
- requirements:
79
- - - ! '>='
80
- - !ruby/object:Gem::Version
81
- version: 1.6.8
82
- type: :runtime
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- none: false
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: 1.6.8
90
- description: Command-line tool and library for onetimesecret.com API
91
- email: delano@onetimesecret.com
92
- executables:
93
- - onetime
39
+ version: '13.0'
40
+ description: The onetime gem has moved to the canonical onetimesecret package.
41
+ email:
42
+ - gems@onetimesecret.com
43
+ executables: []
94
44
  extensions: []
95
- extra_rdoc_files:
96
- - LICENSE.txt
97
- - README.md
45
+ extra_rdoc_files: []
98
46
  files:
99
- - CHANGES.txt
100
47
  - LICENSE.txt
101
48
  - README.md
102
- - Rakefile
103
- - VERSION
104
- - bin/onetime
105
- - gem-public_cert.pem
106
- - lib/onetime/api.rb
107
- - onetime.gemspec
108
49
  homepage: https://github.com/onetimesecret/onetime-ruby
109
- licenses: []
110
- post_install_message:
50
+ licenses:
51
+ - MIT
52
+ metadata:
53
+ source_code_uri: https://github.com/onetimesecret/onetime-ruby
54
+ bug_tracker_uri: https://github.com/onetimesecret/onetime-ruby/issues
55
+ documentation_uri: https://docs.onetimesecret.com/
56
+ changelog_uri: https://github.com/onetimesecret/onetime-ruby/blob/main/CHANGES.txt
57
+ rubygems_mfa_required: 'true'
58
+ post_install_message: |2+
59
+
60
+ The `onetime` gem has moved to `onetimesecret`.
61
+
62
+ Update your Gemfile:
63
+
64
+ gem "onetimesecret", "~> 0.7.0"
65
+
66
+ The Ruby namespace remains `Onetime`, and `require "onetime"` remains
67
+ supported by the canonical gem.
68
+
111
69
  rdoc_options: []
112
70
  require_paths:
113
71
  - lib
114
72
  required_ruby_version: !ruby/object:Gem::Requirement
115
- none: false
116
73
  requirements:
117
- - - ! '>='
74
+ - - ">="
118
75
  - !ruby/object:Gem::Version
119
- version: '0'
76
+ version: '3.1'
120
77
  required_rubygems_version: !ruby/object:Gem::Requirement
121
- none: false
122
78
  requirements:
123
- - - ! '>='
79
+ - - ">="
124
80
  - !ruby/object:Gem::Version
125
81
  version: '0'
126
82
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 1.8.25
129
- signing_key:
130
- specification_version: 3
131
- summary: Command-line tool and library for onetimesecret.com API
83
+ rubygems_version: 3.6.9
84
+ specification_version: 4
85
+ summary: Compatibility package; use the onetimesecret gem
132
86
  test_files: []
87
+ ...
data/CHANGES.txt DELETED
@@ -1,40 +0,0 @@
1
- ONETIME, CHANGES
2
-
3
- #### 0.5.1 (2013-02-12) ###############################
4
-
5
- * ADDED: global recipient parameter for 'generate' and 'share' commands.
6
-
7
- #### 0.5.0 (2013-02-12) ###############################
8
-
9
- * ADDED: Support for getting secrets based on the URI
10
- * ADDED: Command alias 'get' for 'secret'
11
- * ADDED: Explicit support for string format
12
- * FIXED: Confusion around csv support (there is no csv support)
13
- * CHANGE: Disabled checking for tty. Just assume string format.
14
- * CHANGE: 'secret' command returns just the secret message by default (not yaml)
15
-
16
-
17
- #### 0.4.1 (2013-02-12) ###############################
18
-
19
- * CHANGE: All releases will now be signed. See "Installation" in the readme.
20
- * CHANGE: json dependency upgraded from 1.6.4 to 1.6.8
21
-
22
- #### 0.4.0 (2012-01-07) ###############################
23
-
24
- * ADDED: Support for ttl, passphrase, and email recipient
25
- * ADDED: Better error handling
26
- * CHANGE: env variable ONETIME_ACCOUNT -> ONETIME_CUSTID
27
- * CHANGE: global option -u is now -H
28
-
29
-
30
- #### 0.3.1 (2012-01-06) ###############################
31
-
32
- * FIXED: Added httparty to gemspec dependencies
33
- * ADDED: X-Onetime-Client header
34
-
35
-
36
- #### 0.3.0 (2012-01-06) ###############################
37
-
38
- Initial public release
39
-
40
-
data/Rakefile DELETED
@@ -1,50 +0,0 @@
1
- require "rubygems"
2
- require "rake"
3
- require "rake/clean"
4
- require "rdoc/task"
5
-
6
- task :default => ["build"]
7
- CLEAN.include [ 'pkg', 'rdoc' ]
8
- name = "onetime/api"
9
-
10
- $:.unshift File.join(File.dirname(__FILE__), 'lib')
11
- require name
12
- version = Onetime::API::VERSION.to_s
13
-
14
- begin
15
- require "jeweler"
16
- Jeweler::Tasks.new do |s|
17
- s.version = version
18
- s.name = "onetime"
19
- s.executables = ['onetime']
20
- s.summary = "Command-line tool and library for onetimesecret.com API"
21
- s.description = "Command-line tool and library for onetimesecret.com API"
22
- s.email = "delano@onetimesecret.com"
23
- s.homepage = "https://github.com/onetimesecret/onetime-ruby"
24
- s.authors = ["Delano Mandelbaum"]
25
- s.add_dependency('drydock', '>= 0.6.9')
26
- s.add_dependency('httparty', '>= 0.7.7')
27
- s.add_dependency('json', '>= 1.6.8')
28
-
29
- s.signing_key = File.join('/mnt/gem/', 'gem-private_key.pem')
30
- s.cert_chain = ['gem-public_cert.pem']
31
- end
32
- Jeweler::GemcutterTasks.new
33
- rescue LoadError
34
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
35
- end
36
-
37
- RDoc::Task.new do |rdoc|
38
- rdoc.rdoc_dir = "rdoc"
39
- rdoc.title = "#{name} #{version}"
40
- rdoc.generator = 'hanna'
41
- rdoc.main = 'README.rdoc'
42
- rdoc.rdoc_files.include("README*")
43
- rdoc.rdoc_files.include("LICENSE.txt")
44
- rdoc.rdoc_files.include("VERSION")
45
- rdoc.rdoc_files.include("bin/*.rb")
46
- rdoc.rdoc_files.include("lib/**/*.rb")
47
- end
48
-
49
-
50
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.5.1
data/bin/onetime DELETED
@@ -1,228 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- base_path = File.expand_path File.join(File.dirname(__FILE__), '..')
4
- $:.unshift File.join(base_path, 'lib')
5
-
6
- require 'uri'
7
- require 'onetime/api'
8
- require 'drydock'
9
-
10
- class Onetime::CLI
11
- class Definition
12
- extend Drydock
13
-
14
- default :share
15
-
16
- global :H, String, "Base URI (e.g. https://onetimesecret.com/api)"
17
- global :c, :custid, String, "Customer ID (e.g. you@yourcompany.com)"
18
- global :k, :apikey, String, "API key (e.g. 4eb33c6340006d6607c813fc7e707a32f8bf5342)"
19
-
20
- global :r, :recipient, Array, "Email address to deliver the secret link"
21
-
22
- global :f, :format, String, "Output format (json or yaml)"
23
- global :j, :json, "Shorthand for -f json"
24
- global :y, :yaml, "Shorthand for -f yaml"
25
- global :s, :string, "Shorthand for -f string (default)"
26
-
27
- global :D, :debug do
28
- OT::API.debug_output STDERR
29
- end
30
-
31
- global :V, :version do
32
- puts OT::API::VERSION
33
- exit 0
34
- end
35
-
36
- before do |obj|
37
- OT::API.base_uri obj.global.H if obj.global.H
38
- @api = OT::API.new obj.global.custid, obj.global.apikey
39
- obj.global.format = 'yaml' if obj.global.yaml
40
- obj.global.format = 'json' if obj.global.json
41
- obj.global.format = 'string' if obj.global.string
42
- obj.global.format = nil if obj.global.format == 'string'
43
- if obj.global.format && !['json', 'yaml', 'csv'].member?(obj.global.format)
44
- raise RuntimeError, "Unsupported format: #{obj.global.format}"
45
- end
46
- end
47
-
48
- usage "onetime status"
49
- command :status do |obj|
50
- @res = @api.get '/status'
51
- if @res.nil?
52
- raise RuntimeError, 'Could not complete request'
53
- elsif @api.response.code != 200
54
- raise RuntimeError, @res['message']
55
- end
56
- case obj.global.format
57
- when 'json'
58
- puts @res.to_json
59
- when 'yaml'
60
- puts @res.to_yaml
61
- else
62
- msg = @api.anonymous ? 'Anonymous' : @api.custid
63
- STDERR.puts '# Host: %s' % OT::API.base_uri
64
- STDERR.puts '# Account: %s' % msg
65
- puts 'Service Status: %s' % @res[:status]
66
- end
67
- end
68
-
69
- argv :key
70
- usage "onetime metadata <KEY>"
71
- command :metadata do |obj|
72
- raise RuntimeError, "csv not supported" if obj.global.format == 'csv'
73
- raise RuntimeError, "Usage: #{$0} metadata <KEY>" unless obj.argv.key
74
- @res = @api.post '/metadata/%s' % obj.argv.key
75
- if @res.nil?
76
- raise RuntimeError, 'Could not complete request'
77
- elsif @api.response.code != 200
78
- raise RuntimeError, @res['message']
79
- end
80
- case obj.global.format
81
- when 'json'
82
- puts @res.to_json
83
- when 'yaml'
84
- puts @res.to_yaml
85
- else
86
- puts @res.to_yaml
87
- end
88
- end
89
-
90
- option :p, :passphrase, String, "Passphrase to decrypt the secret (only required if one was provided to you)"
91
- argv :key
92
- usage "onetime secret <KEY>"
93
- usage "onetime secret [-p PASSPHRASE] <KEY>"
94
- command :secret do |obj|
95
- raise RuntimeError, "csv not supported" if obj.global.format == 'csv'
96
- raise RuntimeError, "Usage: #{$0} secret <KEY>" unless obj.argv.key
97
- opts = {}
98
- opts[:passphrase] = obj.option.passphrase if obj.option.passphrase
99
- base_uri = URI.parse Onetime::API.base_uri
100
- if obj.argv.key =~ /#{base_uri.hostname}\/secret\/([a-zA-Z0-9]+)/
101
- obj.argv.key = $1
102
- end
103
- @res = @api.post '/secret/%s' % [obj.argv.key], opts
104
- if @res.nil?
105
- raise RuntimeError, 'Could not complete request'
106
- elsif @api.response.code != 200
107
- raise RuntimeError, @res['message']
108
- end
109
- case obj.global.format
110
- when 'json'
111
- puts @res.to_json
112
- when 'yaml'
113
- puts @res.to_yaml
114
- else
115
- puts @res[:value] if @res
116
- end
117
- end
118
- command_alias :secret, :get
119
-
120
- usage "onetime share"
121
- usage "onetime share [-t 3600] [-p PASSPHRASE]"
122
- usage "echo 'your secret' | onetime share"
123
- usage "<path/2/file onetime share"
124
- option :t, :ttl, Integer, "Time-to-live in seconds"
125
- option :p, :passphrase, String, "Passphrase to encrypt the secret (something only you and recipient know)"
126
- option :r, :recipient, Array, "Email address to deliver the secret link"
127
- command :share do |obj|
128
- recipients = [obj.option.recipient, obj.global.recipient].flatten.compact.uniq
129
- begin
130
- if Kernel.select [$stdin], nil, nil, 0
131
- secret_value = STDIN.read
132
- else
133
- STDERR.puts "Paste message here (hit control-D to continue):"
134
- secret_value = ARGF.read
135
- STDERR.puts # new line to let the person know we got it.
136
- end
137
- rescue Interrupt => ex
138
- puts "Exiting..."
139
- exit 0
140
- end
141
- raise RuntimeError, "No secret provided" if secret_value.chomp.empty?
142
- opts = { :secret => secret_value, :ttl => obj.option.ttl, :recipient => recipients }
143
- opts[:passphrase] = obj.option.passphrase if obj.option.passphrase
144
- @res = @api.post '/share', opts
145
- if @res.nil?
146
- raise RuntimeError, 'Could not complete request'
147
- elsif @api.response.code != 200
148
- raise RuntimeError, @res['message']
149
- end
150
- uri = OT::API.web_uri('secret', @res[:secret_key])
151
- case obj.global.format
152
- when 'json'
153
- puts @res.to_json
154
- when 'yaml'
155
- puts @res.to_yaml
156
- else
157
- if @res[:recipient] && !@res[:recipient].compact.empty?
158
- STDERR.puts '# Secret link sent to: %s' % @res[:recipient].join(',')
159
- else
160
- puts uri
161
- end
162
- end
163
- end
164
-
165
- usage "onetime generate"
166
- usage "onetime generate [-t 3600] [-p PASSPHRASE]"
167
- option :t, :ttl, Integer, "Time-to-live in seconds"
168
- option :p, :passphrase, String, "Passphrase to encrypt the secret (something only you and recipient know)"
169
- option :r, :recipient, Array, "Email address to deliver the secret link"
170
- command :generate do |obj|
171
- recipients = [obj.option.recipient, obj.global.recipient].flatten.compact.uniq
172
- opts = { :ttl => obj.option.ttl, :recipient => recipients }
173
- opts[:passphrase] = obj.option.passphrase if obj.option.passphrase
174
- @res = @api.post '/generate', opts
175
- if @res.nil?
176
- raise RuntimeError, 'Could not complete request'
177
- elsif @api.response.code != 200
178
- raise RuntimeError, @res['message']
179
- end
180
- uri, secret_value = OT::API.web_uri('secret', @res[:secret_key]), @res[:value]
181
- case obj.global.format
182
- when 'json'
183
- puts @res.to_json
184
- when 'yaml'
185
- puts @res.to_yaml
186
- when 'csv'
187
- puts [secret_value,uri].join ','
188
- else
189
- msg = 'Your secret (hit return to continue): %s' % secret_value
190
- if @res[:recipient] && !@res[:recipient].compact.empty?
191
- uri = "\e[K\r# Secret link sent to: %s" % [@res[:recipient].join(',').ljust(40, ' ')]
192
- end
193
- eraser = "\e[K\r%s" % [uri] # \e[K\r
194
- print msg
195
- # Check for tty b/c if we're receiving data via STDIN, even if
196
- # we're ignoring it, the stty commands return "stdin isn't a terminal"
197
- if STDIN.tty?
198
- begin
199
- old_stty = `stty -g` # store tty settings
200
- system "stty -echo"
201
- STDIN.getc
202
- rescue Interrupt
203
- ensure
204
- system "stty echo"
205
- system "stty #{old_stty}" # restore stty settings
206
- print eraser
207
- end
208
- else
209
- puts
210
- print uri
211
- end
212
- puts
213
- end
214
- end
215
-
216
- end
217
- end
218
-
219
- begin
220
- Drydock.run! ARGV, STDIN
221
- rescue RuntimeError => ex
222
- STDERR.puts ex.message
223
- exit 1
224
- rescue => ex
225
- puts ex.message
226
- puts ex.backtrace
227
- exit 1
228
- end
data/gem-public_cert.pem DELETED
@@ -1,20 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMQ8wDQYDVQQDDAZkZWxh
3
- bm8xGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZFgNj
4
- b20wHhcNMTMwMjA2MTE1NzQ1WhcNMTQwMjA2MTE1NzQ1WjBBMQ8wDQYDVQQDDAZk
5
- ZWxhbm8xGTAXBgoJkiaJk/IsZAEZFglzb2x1dGlvdXMxEzARBgoJkiaJk/IsZAEZ
6
- FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDg1hMtl0XsMuUK
7
- AKTgYWv3gjj7vuEsE2EjT+vyBg8/LpqVVwZziiaebJT9IZiQ+sCFqbiakj0b53pI
8
- hg1yOaBEmH6/W0L7rwzqaRV9sW1eJs9JxFYQCnd67zUnzj8nnRlOjG+hhIG+Vsij
9
- npsGbt28pefuNZJjO5q2clAlfSniIIHfIsU7/StEYu6FUGOjnwryZ0r5yJlr9RrE
10
- Gs+q0DW8QnZ9UpAfuDFQZuIqeKQFFLE7nMmCGaA+0BN1nLl3fVHNbLHq7Avk8+Z+
11
- ZuuvkdscbHlO/l+3xCNQ5nUnHwq0ADAbMLOlmiYYzqXoWLjmeI6me/clktJCfN2R
12
- oZG3UQvvAgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFMSJOEtHzE4l0azv
13
- M0JK0kKNToK1MAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAtOdE73qx
14
- OH2ydi9oT2hS5f9G0y1Z70Tlwh+VGExyfxzVE9XwC+iPpJxNraiHYgF/9/oky7ZZ
15
- R9q0/tJneuhAenZdiQkX7oi4O3v9wRS6YHoWBxMPFKVRLNTzvVJsbmfpCAlp5/5g
16
- ps4wQFy5mibElGVlOobf/ghqZ25HS9J6kd0/C/ry0AUtTogsL7TxGwT4kbCx63ub
17
- 3vywEEhsJUzfd97GCABmtQfRTldX/j7F1z/5wd8p+hfdox1iibds9ZtfaZA3KzKn
18
- kchWN9B6zg9r1XMQ8BM2Jz0XoPanPe354+lWwjpkRKbFow/ZbQHcCLCq24+N6b6g
19
- dgKfNDzwiDpqCA==
20
- -----END CERTIFICATE-----
data/lib/onetime/api.rb DELETED
@@ -1,136 +0,0 @@
1
-
2
-
3
- require 'httparty'
4
- require 'uri'
5
-
6
- begin
7
- require 'yajl-ruby'
8
- rescue LoadError => ex
9
- require 'json'
10
- end
11
-
12
- begin
13
- require 'yaml'
14
- rescue LoadError => ex
15
- end
16
-
17
-
18
- # Onetime::API - v0.3
19
- #
20
- # A basic client library for the onetimesecret.com API.
21
- #
22
- # Usage:
23
- #
24
- # api = OT::API.new 'delano@onetimesecret.com', '4eb33c6340006d6607c813fc7e707a32f8bf5342'
25
- #
26
- # api.get '/status'
27
- # # => {'status' => 'nominal'}
28
- #
29
- # api.post '/generate', :passphrase => 'yourspecialpassphrase'
30
- # # => {'value' => '3Rg8R2sfD3?a', 'metadata_key' => '...', 'secret_key' => '...'}
31
- #
32
- module Onetime
33
- class API
34
- unless defined?(Onetime::API::HOME)
35
- HOME = File.expand_path File.join(File.dirname(__FILE__), '..', '..')
36
- end
37
- module VERSION
38
- @path = File.join(Onetime::API::HOME, 'VERSION')
39
- class << self
40
- attr_reader :version, :path
41
- def version
42
- @version || read_version
43
- end
44
- def read_version
45
- return if @version
46
- @version = File.read(path).strip!
47
- end
48
- def prerelease?() false end
49
- def to_a() version.split('.') end
50
- def to_s() version end
51
- def inspect() version end
52
- end
53
- end
54
- end
55
- class API
56
- include HTTParty
57
- base_uri 'https://onetimesecret.com/api'
58
- format :json
59
- headers 'X-Onetime-Client' => 'ruby: %s/%s' % [RUBY_VERSION, Onetime::API::VERSION.to_s]
60
- attr_reader :opts, :response, :custid, :key, :default_params, :anonymous
61
- attr_accessor :apiversion
62
- def initialize custid=nil, key=nil, opts={}
63
- unless ENV['ONETIME_HOST'].to_s.empty?
64
- self.class.base_uri ENV['ONETIME_HOST']
65
- end
66
- @apiversion = opts.delete(:apiversion) || opts.delete('apiversion') || 1
67
- @opts = opts
68
- @default_params = {}
69
- @custid = custid || ENV['ONETIME_CUSTID']
70
- @key = key || ENV['ONETIME_APIKEY']
71
- if @custid.to_s.empty? && @key.to_s.empty?
72
- @anonymous = true
73
- elsif @custid.to_s.empty? || @key.to_s.empty?
74
- raise RuntimeError, "You provided a custid without an apikey" if @key.to_s.empty?
75
- raise RuntimeError, "You provided an apikey without a custid" if @custid.to_s.empty?
76
- else
77
- @anonymous = false
78
- opts[:basic_auth] ||= { :username => @custid, :password => @key }
79
- end
80
- end
81
- def get path, params=nil
82
- opts = self.opts.clone
83
- opts[:query] = (params || {}).merge default_params
84
- execute_request :get, path, opts
85
- end
86
- def post path, params=nil
87
- opts = self.opts.clone
88
- opts[:body] = (params || {}).merge default_params
89
- execute_request :post, path, opts
90
- end
91
- def api_path *args
92
- args.unshift ['', "v#{apiversion}"] # force leading slash and version
93
- path = args.flatten.join('/')
94
- path.gsub '//', '/'
95
- end
96
- private
97
- def execute_request meth, path, opts
98
- path = api_path [path]
99
- @response = self.class.send meth, path, opts
100
- self.class.indifferent_params @response.parsed_response
101
- end
102
- class << self
103
- def web_uri *args
104
- uri = URI.parse(OT::API.base_uri)
105
- uri.path = web_path *args
106
- uri
107
- end
108
- def web_path *args
109
- args.unshift [''] # force leading slash
110
- path = args.flatten.join('/')
111
- path.gsub '//', '/'
112
- end
113
- def indifferent_params(params)
114
- if params.is_a?(Hash)
115
- params = indifferent_hash.merge(params)
116
- params.each do |key, value|
117
- next unless value.is_a?(Hash) || value.is_a?(Array)
118
- params[key] = indifferent_params(value)
119
- end
120
- elsif params.is_a?(Array)
121
- params.collect! do |value|
122
- if value.is_a?(Hash) || value.is_a?(Array)
123
- indifferent_params(value)
124
- else
125
- value
126
- end
127
- end
128
- end
129
- end
130
- def indifferent_hash
131
- Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
132
- end
133
- end
134
- end
135
- end
136
- OT = Onetime unless defined?(OT)
data/onetime.gemspec DELETED
@@ -1,56 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "onetime"
8
- s.version = "0.5.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Delano Mandelbaum"]
12
- s.cert_chain = ["gem-public_cert.pem"]
13
- s.date = "2013-02-12"
14
- s.description = "Command-line tool and library for onetimesecret.com API"
15
- s.email = "delano@onetimesecret.com"
16
- s.executables = ["onetime"]
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = [
22
- "CHANGES.txt",
23
- "LICENSE.txt",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/onetime",
28
- "gem-public_cert.pem",
29
- "lib/onetime/api.rb",
30
- "onetime.gemspec"
31
- ]
32
- s.homepage = "https://github.com/onetimesecret/onetime-ruby"
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = "1.8.25"
35
- s.signing_key = "/mnt/gem/gem-private_key.pem"
36
- s.summary = "Command-line tool and library for onetimesecret.com API"
37
-
38
- if s.respond_to? :specification_version then
39
- s.specification_version = 3
40
-
41
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
- s.add_runtime_dependency(%q<drydock>, [">= 0.6.9"])
43
- s.add_runtime_dependency(%q<httparty>, [">= 0.7.7"])
44
- s.add_runtime_dependency(%q<json>, [">= 1.6.8"])
45
- else
46
- s.add_dependency(%q<drydock>, [">= 0.6.9"])
47
- s.add_dependency(%q<httparty>, [">= 0.7.7"])
48
- s.add_dependency(%q<json>, [">= 1.6.8"])
49
- end
50
- else
51
- s.add_dependency(%q<drydock>, [">= 0.6.9"])
52
- s.add_dependency(%q<httparty>, [">= 0.7.7"])
53
- s.add_dependency(%q<json>, [">= 1.6.8"])
54
- end
55
- end
56
-
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- p���4jo��?�vi��ԩ�ܕ٢�t4�h6f<eo!�J��P�M�T-Κ�Uut?�aV%���)������0 ~ �����5\E{2�oD�~�Mɩk�]w�A����H�%;J +�1�y�>�P�Mj]�_��d�j��wf��~��Xey#�}����7O���CǏ>*^QL�vd��ڸ��Ь��[N�*���괁�Aq3���J<\}ys*'�Ĕ�I�4S��D'������~G"���olJ�����c�(�M�QC