kbsecret 0.4.3 → 0.4.4
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 +3 -1
- data/bin/kbsecret-dump-fields +1 -1
- data/bin/kbsecret-env +9 -12
- data/bin/kbsecret-login +8 -12
- data/bin/kbsecret-pass +5 -5
- data/bin/kbsecret-raw-edit +1 -1
- data/bin/kbsecret-todo +3 -3
- data/lib/kbsecret.rb +1 -1
- data/lib/kbsecret/record/abstract.rb +9 -3
- data/lib/kbsecret/session.rb +16 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40118cac4e5abfe1a536fefb044f62266df790b8
|
4
|
+
data.tar.gz: 52f20d03e5855f7609c41e51787e530fa01e7f38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b920a36a162c11b7b94b925ce495f6246a4645711b987ff5c9629845e881934918fc179cbfdd6d2452d858fc800dedbe220edd4b0723c42271f88c3faeb69b5
|
7
|
+
data.tar.gz: 3102a1a4481fdd75a8dfebd4e56543a6fe079b95f5e4405800ff6b3532e0d2e4efb6b151d3c325b55f6edd4d4d1421713452337fe932b617f6a6bf42d12caf8e
|
data/README.md
CHANGED
@@ -40,7 +40,9 @@ Documentation is available on [RubyDoc](http://www.rubydoc.info/gems/kbsecret/).
|
|
40
40
|
|
41
41
|
```bash
|
42
42
|
# create a new login record under the default session
|
43
|
-
$ kbsecret new login gmail
|
43
|
+
$ kbsecret new login gmail
|
44
|
+
Username?
|
45
|
+
Password?
|
44
46
|
|
45
47
|
# list all records under the default session
|
46
48
|
$ kbsecret list
|
data/bin/kbsecret-dump-fields
CHANGED
data/bin/kbsecret-env
CHANGED
@@ -22,18 +22,15 @@ end
|
|
22
22
|
|
23
23
|
session = KBSecret::CLI.ensure_session opts[:session]
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
if opts.all?
|
28
|
-
|
29
|
-
else
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
env_records.find { |r| r.label == l }
|
35
|
-
end.compact
|
36
|
-
end
|
25
|
+
records = session.records :environment
|
26
|
+
|
27
|
+
selected_records = if opts.all?
|
28
|
+
records
|
29
|
+
else
|
30
|
+
records.select do |record|
|
31
|
+
opts.args.include? record.label
|
32
|
+
end
|
33
|
+
end
|
37
34
|
|
38
35
|
selected_records.each do |record|
|
39
36
|
if opts.value_only?
|
data/bin/kbsecret-login
CHANGED
@@ -23,18 +23,14 @@ end
|
|
23
23
|
|
24
24
|
session = KBSecret::CLI.ensure_session opts[:session]
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
selected_records = selected_labels.map do |l|
|
35
|
-
login_records.find { |r| r.label == l }
|
36
|
-
end.compact
|
37
|
-
end
|
26
|
+
records = session.records :login
|
27
|
+
selected_records = if opts.all?
|
28
|
+
records
|
29
|
+
else
|
30
|
+
records.select do |record|
|
31
|
+
opts.args.include? record.label
|
32
|
+
end
|
33
|
+
end
|
38
34
|
|
39
35
|
selected_records.each do |record|
|
40
36
|
if opts.terse?
|
data/bin/kbsecret-pass
CHANGED
@@ -20,12 +20,12 @@ opts = KBSecret::CLI.slop do |o|
|
|
20
20
|
o.bool "-c", "--clipboard", "dump the password in the clipboard"
|
21
21
|
end
|
22
22
|
|
23
|
-
session
|
24
|
-
label
|
25
|
-
|
26
|
-
record = login_records.find { |r| r.label == label }
|
23
|
+
session = KBSecret::CLI.ensure_session opts[:session]
|
24
|
+
label = opts.args.shift
|
25
|
+
record = session[label]
|
27
26
|
|
28
|
-
KBSecret::CLI.die "No such
|
27
|
+
KBSecret::CLI.die "No such record." unless record
|
28
|
+
KBSecret::CLI.die "'#{record}' is not a login record." unless record.type == :login
|
29
29
|
|
30
30
|
if opts.clipboard?
|
31
31
|
Clipboard.copy record.password
|
data/bin/kbsecret-raw-edit
CHANGED
data/bin/kbsecret-todo
CHANGED
@@ -24,10 +24,10 @@ command, label = opts.args.shift 2
|
|
24
24
|
|
25
25
|
KBSecret::CLI.die "Missing subcommand." unless command && label
|
26
26
|
|
27
|
-
|
28
|
-
todo = todo_records.find { |r| r.label == label }
|
27
|
+
todo = session[label]
|
29
28
|
|
30
|
-
KBSecret::CLI.die
|
29
|
+
KBSecret::CLI.die "No such record." unless todo
|
30
|
+
KBSecret::CLI.die "'#{todo}' is not a todo record." unless todo.type == :todo
|
31
31
|
|
32
32
|
case command
|
33
33
|
when "start"
|
data/lib/kbsecret.rb
CHANGED
@@ -11,7 +11,7 @@ require_relative "kbsecret/cli"
|
|
11
11
|
# The primary namespace for kbsecret.
|
12
12
|
module KBSecret
|
13
13
|
# kbsecret's current version
|
14
|
-
VERSION = "0.4.
|
14
|
+
VERSION = "0.4.4"
|
15
15
|
|
16
16
|
# fail very early if the user doesn't have keybase and KBFS running
|
17
17
|
raise Keybase::KeybaseNotRunningError unless Keybase.running?
|
@@ -14,7 +14,7 @@ module KBSecret
|
|
14
14
|
# @return [Integer] the UNIX timestamp marking the record's last modification
|
15
15
|
attr_reader :timestamp
|
16
16
|
|
17
|
-
# @return [
|
17
|
+
# @return [String] the record's label
|
18
18
|
attr_reader :label
|
19
19
|
|
20
20
|
# @return [Symbol] the record's type
|
@@ -86,12 +86,12 @@ module KBSecret
|
|
86
86
|
|
87
87
|
# Create a brand new record, associated with a session.
|
88
88
|
# @param session [Session] the session to associate with
|
89
|
-
# @param label [Symbol] the new record's label
|
89
|
+
# @param label [String, Symbol] the new record's label
|
90
90
|
# @note Creation does *not* sync the new record; see {#sync!} for that.
|
91
91
|
def initialize(session, label)
|
92
92
|
@session = session
|
93
93
|
@timestamp = Time.now.to_i
|
94
|
-
@label = label
|
94
|
+
@label = label.to_s
|
95
95
|
@type = self.class.type
|
96
96
|
@data = {}
|
97
97
|
@path = File.join(session.directory, "#{label}.json")
|
@@ -109,6 +109,12 @@ module KBSecret
|
|
109
109
|
@path = File.join(session.directory, "#{label}.json")
|
110
110
|
end
|
111
111
|
|
112
|
+
# Create a string representation of the current record.
|
113
|
+
# @return [String] the string representation
|
114
|
+
def to_s
|
115
|
+
@label
|
116
|
+
end
|
117
|
+
|
112
118
|
# Create a hash-representation of the current record.
|
113
119
|
# @return [Hash] the hash-representation
|
114
120
|
def to_h
|
data/lib/kbsecret/session.rb
CHANGED
@@ -28,6 +28,13 @@ module KBSecret
|
|
28
28
|
@records = load_records!
|
29
29
|
end
|
30
30
|
|
31
|
+
# @param label [String, Symbol] the label of the record to fetch
|
32
|
+
# @return [Record::Abstract, nil] the record with the requested label, if extant
|
33
|
+
def [](label)
|
34
|
+
@records.find { |r| r.label == label.to_s }
|
35
|
+
end
|
36
|
+
|
37
|
+
# All records (of a given type) in the session.
|
31
38
|
# @param type [String, Symbol] the type of the records to return (or `nil` for all)
|
32
39
|
# @return [Array<Record::Abstract>] records associated with the session
|
33
40
|
def records(type = nil)
|
@@ -38,16 +45,16 @@ module KBSecret
|
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
41
|
-
# @return [Array<
|
48
|
+
# @return [Array<String>] the labels of all records known to the session
|
42
49
|
# @example
|
43
|
-
# session.record_labels # => [
|
50
|
+
# session.record_labels # => ["website1", "apikey1", "website2"]
|
44
51
|
def record_labels
|
45
52
|
records.map(&:label)
|
46
53
|
end
|
47
54
|
|
48
55
|
# Add a record to the session.
|
49
56
|
# @param type [String, Symbol] the type of record (see {Record.record_types})
|
50
|
-
# @param label [Symbol] the new record's label
|
57
|
+
# @param label [String, Symbol] the new record's label
|
51
58
|
# @param args [Array<String>] the record-type specific arguments
|
52
59
|
# @return [void]
|
53
60
|
# @raise UnknownRecordTypeError if the requested type does not exist
|
@@ -61,27 +68,28 @@ module KBSecret
|
|
61
68
|
arity = klass.instance_method(:initialize).arity - 2
|
62
69
|
raise RecordCreationArityError.new(arity, args.size) unless arity == args.size
|
63
70
|
|
64
|
-
record = klass.new(self, label, *args)
|
71
|
+
record = klass.new(self, label.to_s, *args)
|
65
72
|
records << record
|
66
73
|
record.sync!
|
67
74
|
end
|
68
75
|
|
69
76
|
# Delete a record from the session, if it exists. Does nothing if
|
70
77
|
# no such record can be found.
|
71
|
-
# @param
|
78
|
+
# @param label [String, Symbol] the label of the record to delete
|
72
79
|
# @return [void]
|
73
|
-
def delete_record(
|
74
|
-
record = records.find { |r| r.label ==
|
80
|
+
def delete_record(label)
|
81
|
+
record = records.find { |r| r.label == label.to_s }
|
75
82
|
return unless record
|
76
83
|
|
77
84
|
File.delete(record.path)
|
78
85
|
records.delete(record)
|
79
86
|
end
|
80
87
|
|
88
|
+
# @param label [String, Symbol] the label to test for
|
81
89
|
# @return [Boolean] whether or not the session contains a record with the
|
82
90
|
# given label
|
83
91
|
def record?(label)
|
84
|
-
record_labels.include?(label)
|
92
|
+
record_labels.include?(label.to_s)
|
85
93
|
end
|
86
94
|
|
87
95
|
# Delete the entire session.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kbsecret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|