kbsecret 0.1.0 → 0.1.1
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/bin/kbsecret-env +1 -1
- data/bin/kbsecret-list +2 -6
- data/bin/kbsecret-login +1 -1
- data/bin/kbsecret-pass +1 -1
- data/bin/kbsecret-todo +1 -1
- data/lib/kbsecret.rb +1 -1
- data/lib/kbsecret/record.rb +6 -6
- data/lib/kbsecret/record/abstract.rb +4 -4
- data/lib/kbsecret/session.rb +14 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f807d04b3f3365845cb00d88dc4c117815f8338
|
4
|
+
data.tar.gz: d5aa5f00590f7660391758f9408eb567b8ff9258
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb8f5e6d8658c48911ee49b7f2f9cc4127bbb3c92aea221a9b06b9727d15bde4f283170def0f9f9337b40186baa970434b89994ea6050aeace0f31f7c45cd10
|
7
|
+
data.tar.gz: 3a0656fc05c14ae990ceea61619476edf8c67ceb7b21f88e4b092e7894466f69600926f62620f2e1b786832d73c31b239c48f5fc959c3a31d08e97cdd362d84a
|
data/bin/kbsecret-env
CHANGED
data/bin/kbsecret-list
CHANGED
@@ -12,7 +12,7 @@ opts = Slop.parse suppress_errors: true do |o|
|
|
12
12
|
EOS
|
13
13
|
|
14
14
|
o.string "-s", "--session", "the session name", default: :default
|
15
|
-
o.string "-t", "--type", "the type of secrets to list", default:
|
15
|
+
o.string "-t", "--type", "the type of secrets to list", default: nil
|
16
16
|
o.bool "-a", "--show-all", "show everything in each secret (i.e. metadata)"
|
17
17
|
|
18
18
|
o.on "-h", "--help" do
|
@@ -34,11 +34,7 @@ end
|
|
34
34
|
|
35
35
|
session = KBSecret::Session.new label: sess_name
|
36
36
|
|
37
|
-
|
38
|
-
records = session.records.select { |r| r.type == opts[:type] }
|
39
|
-
else
|
40
|
-
records = session.records
|
41
|
-
end
|
37
|
+
records = session.records opts[:type]
|
42
38
|
|
43
39
|
records.each do |record|
|
44
40
|
line = "#{record.label}\n"
|
data/bin/kbsecret-login
CHANGED
data/bin/kbsecret-pass
CHANGED
@@ -38,7 +38,7 @@ end
|
|
38
38
|
|
39
39
|
session = KBSecret::Session.new label: sess_name
|
40
40
|
label = opts.args.shift
|
41
|
-
login_records = session.records
|
41
|
+
login_records = session.records :login
|
42
42
|
record = login_records.find { |r| r.label == label }
|
43
43
|
|
44
44
|
abort("Fatal: No such login record.") unless record
|
data/bin/kbsecret-todo
CHANGED
@@ -42,7 +42,7 @@ command, label = opts.args.shift 2
|
|
42
42
|
|
43
43
|
abort("Fatal: Missing subcommand.") unless command && label
|
44
44
|
|
45
|
-
todo_records = session.records
|
45
|
+
todo_records = session.records :todo
|
46
46
|
todo = todo_records.find { |r| r.label == label }
|
47
47
|
|
48
48
|
abort("Fatal: No such todo record.") unless todo
|
data/lib/kbsecret.rb
CHANGED
@@ -8,7 +8,7 @@ require_relative "kbsecret/session"
|
|
8
8
|
# The primary namespace for kbsecret.
|
9
9
|
module KBSecret
|
10
10
|
# kbsecret's current version
|
11
|
-
VERSION = "0.1.
|
11
|
+
VERSION = "0.1.1".freeze
|
12
12
|
|
13
13
|
# fail very early if the user doesn't have keybase and KBFS running
|
14
14
|
raise Keybase::KeybaseNotRunningError unless Keybase.running?
|
data/lib/kbsecret/record.rb
CHANGED
@@ -15,21 +15,21 @@ module KBSecret
|
|
15
15
|
klasses
|
16
16
|
end
|
17
17
|
|
18
|
-
# @return [Array<
|
18
|
+
# @return [Array<Symbol>] the types of all records
|
19
19
|
def self.record_types
|
20
20
|
record_classes.map(&:type)
|
21
21
|
end
|
22
22
|
|
23
|
-
# @param type [String] the record type
|
23
|
+
# @param type [String, Symbol] the record type
|
24
24
|
# @return [Class, nil] the record class corresponding to the given type
|
25
25
|
def self.class_for(type)
|
26
|
-
record_classes.find { |c| c.type == type }
|
26
|
+
record_classes.find { |c| c.type == type.to_sym }
|
27
27
|
end
|
28
28
|
|
29
|
-
# @param type [String] the record type
|
29
|
+
# @param type [String, Symbol] the record type
|
30
30
|
# @return [Boolean] whether a record class exists of the given type
|
31
31
|
def self.type?(type)
|
32
|
-
record_types.include?(type)
|
32
|
+
record_types.include?(type.to_sym)
|
33
33
|
end
|
34
34
|
|
35
35
|
# Load a record by path into the given session.
|
@@ -39,7 +39,7 @@ module KBSecret
|
|
39
39
|
# @api private
|
40
40
|
def self.load_record!(session, path)
|
41
41
|
hsh = JSON.parse(File.read(path), symbolize_names: true)
|
42
|
-
klass = record_classes.find { |c| c.type == hsh[:type] }
|
42
|
+
klass = record_classes.find { |c| c.type == hsh[:type].to_sym }
|
43
43
|
klass.load!(session, hsh) if klass
|
44
44
|
end
|
45
45
|
end
|
@@ -38,11 +38,11 @@ module KBSecret
|
|
38
38
|
@fields
|
39
39
|
end
|
40
40
|
|
41
|
-
# @return [
|
41
|
+
# @return [Symbol] the record's type
|
42
42
|
# @example
|
43
|
-
# KBSecret::Record::Abstract.type # =>
|
43
|
+
# KBSecret::Record::Abstract.type # => :abstract
|
44
44
|
def type
|
45
|
-
name.split("::").last.downcase
|
45
|
+
name.split("::").last.downcase.to_sym
|
46
46
|
end
|
47
47
|
|
48
48
|
# Load the given hash-representation into a record.
|
@@ -78,7 +78,7 @@ module KBSecret
|
|
78
78
|
def initialize_from_hash(hsh)
|
79
79
|
@timestamp = hsh[:timestamp]
|
80
80
|
@label = hsh[:label]
|
81
|
-
@type = hsh[:type]
|
81
|
+
@type = hsh[:type].to_sym
|
82
82
|
@data = hsh[:data]
|
83
83
|
end
|
84
84
|
|
data/lib/kbsecret/session.rb
CHANGED
@@ -8,8 +8,9 @@ module KBSecret
|
|
8
8
|
# @return [Hash] the session-specific configuration, from
|
9
9
|
# {Config::CONFIG_FILE}
|
10
10
|
attr_reader :config
|
11
|
+
|
12
|
+
# @return [String] the fully-qualified path of the session
|
11
13
|
attr_reader :directory
|
12
|
-
attr_reader :records
|
13
14
|
|
14
15
|
# @param label [Symbol] the label of the session to initialize
|
15
16
|
# @note This does not *create* a new session, but loads one already
|
@@ -23,6 +24,16 @@ module KBSecret
|
|
23
24
|
@records = load_records!
|
24
25
|
end
|
25
26
|
|
27
|
+
# @param type [String, Symbol] the type of the records to return (or `nil` for all)
|
28
|
+
# @return [Array<Record::Abstract>] records associated with the session
|
29
|
+
def records(type = nil)
|
30
|
+
if type
|
31
|
+
@records.select { |r| r.type == type.to_sym }
|
32
|
+
else
|
33
|
+
@records
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
26
37
|
# @return [Array<Symbol>] the labels of all records known to the session
|
27
38
|
# @example
|
28
39
|
# session.record_labels # => [:website1, :apikey1, :website2]
|
@@ -31,14 +42,14 @@ module KBSecret
|
|
31
42
|
end
|
32
43
|
|
33
44
|
# Add a record to the session.
|
34
|
-
# @param type [String] the type of record (see {Record.record_types})
|
45
|
+
# @param type [String, Symbol] the type of record (see {Record.record_types})
|
35
46
|
# @param label [Symbol] the new record's label
|
36
47
|
# @param args [Array<String>] the record-type specific arguments
|
37
48
|
# @return [void]
|
38
49
|
# @raise RecordCreationArityError if the number of specified record
|
39
50
|
# arguments does not match the record type's constructor
|
40
51
|
def add_record(type, label, *args)
|
41
|
-
klass = Record.record_classes.find { |k| k.type == type }
|
52
|
+
klass = Record.record_classes.find { |k| k.type == type.to_sym }
|
42
53
|
arity = klass.instance_method(:initialize).arity - 2
|
43
54
|
|
44
55
|
unless arity == args.size
|
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.1.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: keybase-unofficial
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.6.
|
133
|
+
rubygems_version: 2.6.11
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: kbsecret - A KBFS (Keybase) backed secret manager.
|