onetime 0.4.1 → 0.5.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.
data.tar.gz.sig CHANGED
Binary file
data/CHANGES.txt CHANGED
@@ -1,5 +1,15 @@
1
1
  ONETIME, CHANGES
2
2
 
3
+ #### 0.5.0 (2013-02-12) ###############################
4
+
5
+ * ADDED: Support for getting secrets based on the URI
6
+ * ADDED: Command alias 'get' for 'secret'
7
+ * ADDED: Explicit support for string format
8
+ * FIXED: Confusion around csv support (there is no csv support)
9
+ * CHANGE: Disabled checking for tty. Just assume string format.
10
+ * CHANGE: 'secret' command returns just the secret message by default (not yaml)
11
+
12
+
3
13
  #### 0.4.1 (2013-02-12) ###############################
4
14
 
5
15
  * CHANGE: All releases will now be signed. See "Installation" in the readme.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # One-Time Secret #
1
+ # One-Time Secret 0.5 #
2
2
 
3
3
  **Keep sensitive info out of your chat logs & email.**
4
4
 
@@ -35,6 +35,18 @@ And you can read from a file:
35
35
  https://onetimesecret.com/secret/er5djg1wodsp5m32oyym489bnuhsfp6
36
36
 
37
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
+
38
50
  ## Output Format ##
39
51
 
40
52
  `onetime` also supports YAML, JSON, and to a limited extent CSV outputs. Specify the format using the `-f ` global option:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
data/bin/onetime CHANGED
@@ -3,6 +3,7 @@
3
3
  base_path = File.expand_path File.join(File.dirname(__FILE__), '..')
4
4
  $:.unshift File.join(base_path, 'lib')
5
5
 
6
+ require 'uri'
6
7
  require 'onetime/api'
7
8
  require 'drydock'
8
9
 
@@ -19,6 +20,7 @@ class Onetime::CLI
19
20
  global :f, :format, String, "Output format (json or yaml)"
20
21
  global :j, :json, "Shorthand for -f json"
21
22
  global :y, :yaml, "Shorthand for -f yaml"
23
+ global :s, :string, "Shorthand for -f string (default)"
22
24
 
23
25
  global :D, :debug do
24
26
  OT::API.debug_output STDERR
@@ -34,22 +36,11 @@ class Onetime::CLI
34
36
  @api = OT::API.new obj.global.custid, obj.global.apikey
35
37
  obj.global.format = 'yaml' if obj.global.yaml
36
38
  obj.global.format = 'json' if obj.global.json
39
+ obj.global.format = 'string' if obj.global.string
37
40
  obj.global.format = nil if obj.global.format == 'string'
38
41
  if obj.global.format && !['json', 'yaml', 'csv'].member?(obj.global.format)
39
42
  raise RuntimeError, "Unsupported format: #{obj.global.format}"
40
43
  end
41
- if !STDOUT.tty? && !obj.global.format
42
- raise RuntimeError, "No tty. Must specify an output format. See #{$0} generate -h"
43
- end
44
- end
45
-
46
- after do |obj|
47
- case obj.global.format
48
- when 'json'
49
- puts @res.to_json
50
- when 'yaml'
51
- puts @res.to_yaml
52
- end
53
44
  end
54
45
 
55
46
  usage "onetime status"
@@ -60,7 +51,12 @@ class Onetime::CLI
60
51
  elsif @api.response.code != 200
61
52
  raise RuntimeError, @res['message']
62
53
  end
63
- unless obj.global.format
54
+ case obj.global.format
55
+ when 'json'
56
+ puts @res.to_json
57
+ when 'yaml'
58
+ puts @res.to_yaml
59
+ else
64
60
  msg = @api.anonymous ? 'Anonymous' : @api.custid
65
61
  STDERR.puts '# Host: %s' % OT::API.base_uri
66
62
  STDERR.puts '# Account: %s' % msg
@@ -79,7 +75,12 @@ class Onetime::CLI
79
75
  elsif @api.response.code != 200
80
76
  raise RuntimeError, @res['message']
81
77
  end
82
- unless obj.global.format
78
+ case obj.global.format
79
+ when 'json'
80
+ puts @res.to_json
81
+ when 'yaml'
82
+ puts @res.to_yaml
83
+ else
83
84
  puts @res.to_yaml
84
85
  end
85
86
  end
@@ -93,16 +94,26 @@ class Onetime::CLI
93
94
  raise RuntimeError, "Usage: #{$0} secret <KEY>" unless obj.argv.key
94
95
  opts = {}
95
96
  opts[:passphrase] = obj.option.passphrase if obj.option.passphrase
97
+ base_uri = URI.parse Onetime::API.base_uri
98
+ if obj.argv.key =~ /#{base_uri.hostname}\/secret\/([a-zA-Z0-9]+)/
99
+ obj.argv.key = $1
100
+ end
96
101
  @res = @api.post '/secret/%s' % [obj.argv.key], opts
97
102
  if @res.nil?
98
103
  raise RuntimeError, 'Could not complete request'
99
104
  elsif @api.response.code != 200
100
105
  raise RuntimeError, @res['message']
101
106
  end
102
- unless obj.global.format
107
+ case obj.global.format
108
+ when 'json'
109
+ puts @res.to_json
110
+ when 'yaml'
103
111
  puts @res.to_yaml
112
+ else
113
+ puts @res[:value] if @res
104
114
  end
105
115
  end
116
+ command_alias :secret, :get
106
117
 
107
118
  usage "onetime share"
108
119
  usage "onetime share [-t 3600] [-p PASSPHRASE]"
@@ -134,7 +145,12 @@ class Onetime::CLI
134
145
  raise RuntimeError, @res['message']
135
146
  end
136
147
  uri = OT::API.web_uri('secret', @res[:secret_key])
137
- if obj.global.format == 'csv' || obj.global.format.nil?
148
+ case obj.global.format
149
+ when 'json'
150
+ puts @res.to_json
151
+ when 'yaml'
152
+ puts @res.to_yaml
153
+ else
138
154
  if @res[:recipient] && !@res[:recipient].compact.empty?
139
155
  STDERR.puts '# Secret link sent to: %s' % @res[:recipient].join(',')
140
156
  else
@@ -158,10 +174,14 @@ class Onetime::CLI
158
174
  raise RuntimeError, @res['message']
159
175
  end
160
176
  uri, secret_value = OT::API.web_uri('secret', @res[:secret_key]), @res[:value]
161
- STDERR.puts @res.inspect if obj.global.debug
162
- if obj.global.format == 'csv'
177
+ case obj.global.format
178
+ when 'json'
179
+ puts @res.to_json
180
+ when 'yaml'
181
+ puts @res.to_yaml
182
+ when 'csv'
163
183
  puts [secret_value,uri].join ','
164
- elsif obj.global.format.nil?
184
+ else
165
185
  msg = 'Your secret (hit return to continue): %s' % secret_value
166
186
  if @res[:recipient] && !@res[:recipient].compact.empty?
167
187
  uri = "\e[K\r# Secret link sent to: %s" % [@res[:recipient].join(',').ljust(40, ' ')]
data/onetime.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "onetime"
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Delano Mandelbaum"]
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "bin/onetime",
28
+ "gem-public_cert.pem",
28
29
  "lib/onetime/api.rb",
29
30
  "onetime.gemspec"
30
31
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onetime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
metadata.gz.sig CHANGED
Binary file