safedb 0.3.1009 → 0.3.1010

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93cd8e2ba6cd82c1825476110054999fc168d533
4
- data.tar.gz: fe80242921b7acefc7344d0604270bea4c570b3f
3
+ metadata.gz: cc83fe6e9b8f141eef721eeb62608f57535aaedd
4
+ data.tar.gz: b7c90295820373a1b04ce3dc95574614e74ea132
5
5
  SHA512:
6
- metadata.gz: dd195060d76f1fdab168946ee71c8b0d6edee7980e31f46310d5ab19c0c60502bba4c037ffc5ec2ec39988dca6eed27228495e19c62daf15bc52a01e6fc5c698
7
- data.tar.gz: 7b600ed027658cbbdadb4ba76621c26f9ef01b041ff6df3157cb192ebf57187ba548b33dbef2e92f40dafa858f5a263b64944940301a8cbfbba13123265cb63e
6
+ metadata.gz: ed02288410213a27a4b6229e576355200176332b29a3598c15d1ea21af14717acfb18d5fdd8f2f6cb9177cfc6719863f68a224f387bed2298ccc74a691b38f0b
7
+ data.tar.gz: c4d63d2ee433403d931edac75093975da0a8909f69f4d2c300e503f481bcd00c80140d9765720030009ccc6f079d926dd44eed7ef435d1e9a54f5e6e12149de1
data/lib/interprete.rb CHANGED
@@ -203,9 +203,9 @@ class Interprete < Thor
203
203
  # Description of the export use case command.
204
204
  desc "export", "exports the book or chapter or the mini dictionary at verse."
205
205
 
206
- # Export the entire book if no chapter and verse is specified (achieved with a safe close),
207
- # or the chapter if only the chapter is open (safe shut or safe open <<chapter>>, or the
208
- # mini-dictionary at the verse if both chapter and verse are open.
206
+ # Export one, some or all chapters, verses and lines within the logged in book.
207
+ # The --print flag demands that the exported text goes to stdout otherwise it
208
+ # will be placed in an aptly named file in the present working directory.
209
209
  def export
210
210
  log.info(x) { "[usecase] ~> export book chapter content or dictionary at verse in JSON format." }
211
211
  SafeDb::Export.new.flow_of_events
@@ -856,62 +856,6 @@ module SafeDb
856
856
  end
857
857
 
858
858
 
859
- # Register the URL to the <b>frontend keystore</b> that is tied to
860
- # this application instance on this workstation (and user). The default
861
- # keystore sits on an accessible filesystem that is preferably a
862
- # removable drive (like a USB key or phone) which allows the keys to
863
- # your secrets to travel with you in your pocket.
864
- #
865
- # <b>Changing the Keystore Url</b>
866
- #
867
- # If the keystore url has already been configured this method will overwrite
868
- # (thereby updating) it.
869
- #
870
- # <b>Changing the Keystore Url</b>
871
- #
872
- # The keystore directives in the global configuration file looks like this.
873
- #
874
- # [keystore.ids]
875
- # dxEy-v2w3-x7y8 = /media/usb_key/family.creds
876
- # 47S3-Nv0w-8SYf = /media/usb_key/friend.creds
877
- # 3Dds-8Tts-Jy2G = /media/usb_key/office.creds
878
- #
879
- # <b>Which Use Case Sets the Keystore Url?</b>
880
- #
881
- # The keystore url must be provided <b>the very first time</b> init
882
- # is called for an app instance on a machine. If the configuration
883
- # is wiped, the next initialize use case must again provide it.
884
- #
885
- # <b>How to Add (Extend) Storage Services</b>
886
- #
887
- # We could use Redis, PostgreSQL, even a Rest API to provide storage
888
- # services. To extend it - make a keystore ID boss its own section and
889
- # then add keypairs like
890
- #
891
- # - the keystore URL
892
- # - the keystore Type (or interface class)
893
- # - keystore create destroy markers
894
- #
895
- # @param keystore_url [String]
896
- # The keystore url points to where the key metadata protecting
897
- # this application instance lives. The simplest keystores are
898
- # based on files and for them this url is just a folder path.
899
- #
900
- # @raise [KeyError]
901
- #
902
- # The keystore URL cannot be <b>NEW</b>. The <b>NEW acronym</b> asserts
903
- # that the attribute is
904
- #
905
- # - neither <b>N</b>il
906
- # - nor <b>E</b>mpty
907
- # - nor <b>W</b>hitespace only
908
- #
909
- def register_keystore keystore_url
910
- KeyError.not_new( keystore_url, self )
911
- @keymap.write( @aim_id, KEYSTORE_IDENTIFIER_KEY, keystore_url )
912
- end
913
-
914
-
915
859
  # Generate a new set of envelope breadcrumbs, derive the new envelope
916
860
  # filepath, then <b>encrypt</b> the raw envelope content, and write the
917
861
  # resulting ciphertext out into the new file.
@@ -1118,6 +1062,35 @@ module SafeDb
1118
1062
  end
1119
1063
 
1120
1064
 
1065
+ # This method depends on {use_application_domain} which sets
1066
+ # the application ID against the session identity so only call
1067
+ # it if we are in a logged in state.
1068
+ #
1069
+ # NOTE this will NOT be set until the session is logged in so
1070
+ # the call fails before that. For this reason do not call this
1071
+ # method from outside this class. If the domain name is
1072
+ # available use {KeyId.derive_app_instance_identifier} instead.
1073
+ def self.read_app_id()
1074
+
1075
+ aim_id = read_aim_id()
1076
+ keypairs = KeyPair.new( MACHINE_CONFIG_FILE )
1077
+ keypairs.use( aim_id )
1078
+ return keypairs.get( APP_INSTANCE_ID_KEY )
1079
+
1080
+ end
1081
+
1082
+
1083
+ def self.read_aim_id()
1084
+
1085
+ session_identifier = KeyId.derive_session_id( to_token() )
1086
+
1087
+ keypairs = KeyPair.new( MACHINE_CONFIG_FILE )
1088
+ keypairs.use( SESSION_APP_DOMAINS )
1089
+ return keypairs.get( session_identifier )
1090
+
1091
+ end
1092
+
1093
+
1121
1094
  private
1122
1095
 
1123
1096
 
@@ -1230,35 +1203,6 @@ module SafeDb
1230
1203
  end
1231
1204
 
1232
1205
 
1233
- # This method depends on {use_application_domain} which sets
1234
- # the application ID against the session identity so only call
1235
- # it if we are in a logged in state.
1236
- #
1237
- # NOTE this will NOT be set until the session is logged in so
1238
- # the call fails before that. For this reason do not call this
1239
- # method from outside this class. If the domain name is
1240
- # available use {KeyId.derive_app_instance_identifier} instead.
1241
- def self.read_app_id()
1242
-
1243
- aim_id = read_aim_id()
1244
- keypairs = KeyPair.new( MACHINE_CONFIG_FILE )
1245
- keypairs.use( aim_id )
1246
- return keypairs.get( APP_INSTANCE_ID_KEY )
1247
-
1248
- end
1249
-
1250
-
1251
- def self.read_aim_id()
1252
-
1253
- session_identifier = KeyId.derive_session_id( to_token() )
1254
-
1255
- keypairs = KeyPair.new( MACHINE_CONFIG_FILE )
1256
- keypairs.use( SESSION_APP_DOMAINS )
1257
- return keypairs.get( session_identifier )
1258
-
1259
- end
1260
-
1261
-
1262
1206
  def self.get_crumbs_db_from_domain_name( domain_name )
1263
1207
 
1264
1208
  KeyError.not_new( domain_name, self )
@@ -2,34 +2,55 @@
2
2
 
3
3
  module SafeDb
4
4
 
5
- # Export the entire book if no chapter and verse is specified (achieved with a safe close),
6
- # or the chapter if only the chapter is open (safe shut or safe open <<chapter>>, or the
7
- # mini-dictionary at the verse if both chapter and verse are open.
5
+ # Export one, some or all chapters, verses and lines within the logged in book.
6
+ #
7
+ # == Aspirational Feature
8
+ #
9
+ # The --print flag demands that the exported text goes to stdout otherwise it
10
+ # will be placed in an aptly named file in the present working directory.
8
11
  class Export < UseCase
9
12
 
10
- def get_chapter_data( chapter_key )
11
- return KeyDb.from_json( KeyApi.content_unlock( chapter_key ) )
12
- end
13
-
14
13
  def execute
15
14
 
16
15
  return unless ops_key_exists?
17
16
  master_db = KeyApi.read_master_db()
18
17
 
19
- return if unopened_envelope?( master_db )
18
+ puts ""
19
+ puts "### #############################################################\n"
20
+ puts "### Book Birthday =>> #{KeyApi.to_db_create_date(master_db)}\n"
21
+ puts "### The Book Name =>> #{KeyApi.to_db_domain_name(master_db)}\n"
22
+ puts "### The Book (Id) =>> #{KeyApi.to_db_domain_id(master_db)}\n"
23
+ puts "### #############################################################\n"
24
+ puts "--- --------------------------------------------------------------\n"
25
+
26
+ chapters = KeyApi.to_matching_dictionary( master_db, ENVELOPE_KEY_PREFIX )
27
+ export_filename = "safedb.book-#{KeyApi.read_app_id()}-#{KeyNow.yyjjj_hhmm_ss_nanosec()}.json"
28
+ export_filepath = File.join( Dir.pwd, export_filename )
29
+
30
+ exported_struct = {}
31
+ verse_count = 0
20
32
 
21
- chapter_id = ENVELOPE_KEY_PREFIX + master_db[ ENV_PATH ]
22
- has_chapter = KeyApi.db_envelope_exists?( master_db[ chapter_id ] )
33
+ chapters.each_pair do | chapter_name, crumb_dictionary |
34
+
35
+ chapter_struct = KeyDb.from_json( KeyApi.content_unlock( crumb_dictionary ) )
36
+ verse_count += chapter_struct.length
37
+ exported_struct.store( chapter_name, chapter_struct )
23
38
 
24
- unless has_chapter
25
- puts "{}"
26
- return
27
39
  end
28
40
 
29
- chapter_data = get_chapter_data( master_db[ chapter_id ] )
30
- puts JSON.pretty_generate( chapter_data )
41
+ File.write( export_filepath, JSON.pretty_generate( exported_struct ) )
42
+
43
+ puts ""
44
+ puts "Number of chapters exported >> #{chapters.length}"
45
+ puts "Number of verses exported >> #{verse_count}"
46
+ puts "The export filename is #{export_filename}"
47
+ puts "The Present Working Directory is #{Dir.pwd}"
48
+ puts ""
49
+
50
+ puts "--- --------------------------------------------------------------\n"
51
+ puts "### #############################################################\n"
52
+ puts ""
31
53
 
32
- return
33
54
 
34
55
  end
35
56
 
data/lib/usecase/init.rb CHANGED
@@ -48,10 +48,6 @@ module SafeDb
48
48
  KeyApi.setup_domain_keys( @domain_name, domain_password, create_header() )
49
49
  print_domain_initialized
50
50
 
51
- # --> unless @base_path.nil?
52
- # --> key_api.register_keystore( @base_path )
53
- # --> end
54
-
55
51
  end
56
52
 
57
53
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SafeDb
2
- VERSION = "0.3.1009"
2
+ VERSION = "0.3.1010"
3
3
  end
data/safedb.gemspec CHANGED
@@ -29,9 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'thor', '~> 0.20'
30
30
  spec.add_dependency 'inifile', '~> 3.0'
31
31
 
32
- spec.add_development_dependency "bundler"
32
+ spec.add_development_dependency "bundler", "~> 0"
33
33
  spec.add_development_dependency "cucumber", "~> 2.0"
34
34
  spec.add_development_dependency "aruba", "~> 1.0.0-alpha.1"
35
- spec.add_development_dependency "gem-release"
35
+ spec.add_development_dependency "gem-release", "~> 0"
36
36
 
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safedb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1009
4
+ version: 0.3.1010
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apollo Akora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-10 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -98,14 +98,14 @@ dependencies:
98
98
  name: gem-release
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: safe is a credentials manager for the linux command line written in Ruby.