waylon-core 0.2.1 → 0.2.4

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
  SHA256:
3
- metadata.gz: 4b2b3afe461da0b2a61930ff43324ffc820bb596e88de8f36daed751a8ec68fa
4
- data.tar.gz: 2901833fc47c1ab6f8778137de3b3c917cdaf464d09138caac82ec74e45edbe6
3
+ metadata.gz: 0d0e47ec62eadd0848b4538d1bb32238b7e769f09500d536925cbd7d4367be68
4
+ data.tar.gz: 0ecd0c0d42d07861138d8df7170cb49f9eab7bf9a142844bbca44c57d1222bff
5
5
  SHA512:
6
- metadata.gz: 61e60d22426e107eba2b3b07ff3481c6be533cb658d6b8cff402af18c947b9d9e8cd933b1bb137922410741445f83331418552ce3d3e79e290b1f75588bb41d8
7
- data.tar.gz: b98cc02351ac0092fbc138c139c8ef1a3c87a5067b4f4890a0937d6c24af60088c4db4b570158a0cd0f79089493443f29aea8fa37c1d3a5d0e64100702e43706
6
+ metadata.gz: a9dcad0d9c4ad06afa6579d0a38daa70733fc8a0c692fb9f12b52ddd49f4ab998768ffbd92bfe7fc3a54b5b6691f91f4719c882d730e824364ea5adb190119b3
7
+ data.tar.gz: 94867f2bb0fde6993ded3026d827c36dbc4af5e3979281a005feea6f202a2e59a700b72ad2bf368d16add33eee9e631451d9aba76b38eb38d04a9c422097e234
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waylon-core (0.2.1)
4
+ waylon-core (0.2.4)
5
5
  addressable (~> 2.8)
6
6
  faraday (~> 1.8)
7
7
  i18n (~> 1.8)
@@ -17,6 +17,7 @@ GEM
17
17
  addressable (2.8.1)
18
18
  public_suffix (>= 2.0.2, < 6.0)
19
19
  ast (2.4.2)
20
+ coderay (1.1.3)
20
21
  concurrent-ruby (1.1.10)
21
22
  connection_pool (2.2.5)
22
23
  diff-lcs (1.5.0)
@@ -48,6 +49,7 @@ GEM
48
49
  i18n (1.12.0)
49
50
  concurrent-ruby (~> 1.0)
50
51
  json (2.6.2)
52
+ method_source (1.0.0)
51
53
  moneta (1.5.1)
52
54
  mono_logger (1.1.1)
53
55
  multi_json (1.15.0)
@@ -58,6 +60,9 @@ GEM
58
60
  parallel (1.22.1)
59
61
  parser (3.1.2.1)
60
62
  ast (~> 2.4.1)
63
+ pry (0.14.1)
64
+ coderay (~> 1.1)
65
+ method_source (~> 1.0)
61
66
  public_suffix (5.0.0)
62
67
  puma (5.6.5)
63
68
  nio4r (~> 2.0)
@@ -135,6 +140,7 @@ PLATFORMS
135
140
 
136
141
  DEPENDENCIES
137
142
  bundler (~> 2.3)
143
+ pry (~> 0.14)
138
144
  rake (~> 13.0)
139
145
  rspec (~> 3.10)
140
146
  rubocop (~> 1.23)
data/Rakefile CHANGED
@@ -19,5 +19,9 @@ end
19
19
  task default: %i[spec rubocop yard]
20
20
 
21
21
  task :demo do
22
+ require "pry"
23
+ Waylon::Logger.logger = ::Logger.new("/dev/null")
24
+ Waylon::Cache.storage = Moneta.new(:Cookie)
25
+ Waylon::Storage.storage = Moneta.new(:Cookie)
22
26
  require "waylon/rspec/test_server"
23
27
  end
@@ -19,7 +19,7 @@ require "waylon/rspec/test_worker"
19
19
  config = Waylon::Config.instance
20
20
  config.load_env
21
21
 
22
- Waylon::Cache.store = Moneta.new(:Cookie)
22
+ Waylon::Cache.storage = Moneta.new(:Cookie)
23
23
  Waylon::Logger.log("Found Global Admins: #{config.admins}")
24
24
 
25
25
  Waylon::RSpec::TestUser.find_or_create(
@@ -100,6 +100,8 @@ def handle_input(body, from: this_user, privately: true)
100
100
  elsif ["su", "su -", "su admin", "su - admin"].include?(body)
101
101
  puts 'Admin enabled! Use "exit" to go back to a normal user.'
102
102
  @admin_enabled = true
103
+ elsif @admin_enabled && %w[irb pry].include?(body)
104
+ pry
103
105
  else
104
106
  message_count = Waylon::RSpec::TestSense.sent_messages.size
105
107
 
@@ -9,7 +9,7 @@ module Waylon
9
9
  )
10
10
 
11
11
  def self.cipher
12
- key_bytes = RbNaCl::Hash.sha256(ENV.fetch("ENCRYPTION_KEY", "thisisVeryUnsafe4U"))[0..31]
12
+ key_bytes = RbNaCl::Hash.sha256(encryption_key)[0..31]
13
13
  RbNaCl::SimpleBox.from_secret_key(key_bytes)
14
14
  end
15
15
 
@@ -21,6 +21,15 @@ module Waylon
21
21
  storage.delete(key)
22
22
  end
23
23
 
24
+ def self.encryption_key
25
+ ENV.fetch("ENCRYPTION_KEY", "thisisVeryUnsafe4U")
26
+ end
27
+
28
+ def self.encryption_key_fingerprint
29
+ base = RbNaCl::Hash.sha256(encryption_key)[0..15]
30
+ Base64.urlsafe_encode64(RbNaCl::Hash.sha256(base)[0..7])
31
+ end
32
+
24
33
  def self.key?(name)
25
34
  storage.key?(name)
26
35
  end
@@ -30,7 +39,11 @@ module Waylon
30
39
  raw = storage.load(key)
31
40
  return nil unless raw
32
41
 
33
- decoded = Base64.decode64(raw)
42
+ wrapper = JSON.parse(raw)
43
+ value = wrapper["data"]
44
+ return nil unless value
45
+
46
+ decoded = Base64.decode64(value)
34
47
  plain = this_cipher.decrypt(decoded)
35
48
  JSON.parse(plain)
36
49
  end
@@ -47,7 +60,8 @@ module Waylon
47
60
  this_cipher = cipher
48
61
  encrypted = this_cipher.encrypt(value.to_json)
49
62
  encoded = Base64.encode64(encrypted)
50
- storage.store(key, encoded)
63
+ wrapper = { cipher: cipher.class.name, data: encoded, key: encryption_key_fingerprint }
64
+ storage.store(key, wrapper.to_json)
51
65
  end
52
66
  end
53
67
  end
@@ -6,7 +6,7 @@ module Waylon
6
6
  VERSION = [
7
7
  0, # Major
8
8
  2, # Minor
9
- 1 # Patch
9
+ 4 # Patch
10
10
  ].join(".")
11
11
  end
12
12
  end
data/waylon-core.gemspec CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "resque", "~> 2.2"
38
38
 
39
39
  spec.add_development_dependency "bundler", "~> 2.3"
40
+ spec.add_development_dependency "pry", "~> 0.14"
40
41
  spec.add_development_dependency "rake", "~> 13.0"
41
42
  spec.add_development_dependency "rspec", "~> 3.10"
42
43
  spec.add_development_dependency "rubocop", "~> 1.23"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waylon-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-30 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '2.3'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.14'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.14'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rake
141
155
  requirement: !ruby/object:Gem::Requirement