waylon-core 0.1.5 → 0.1.6

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: 443bc0d5a5a87010e8c006d2882631ef323ed5c06ed343e6ca1f5cb080042c33
4
- data.tar.gz: 10812a5cd59babb662a9ef73f0c68146c2e736605f383047e08150375057c78a
3
+ metadata.gz: 57bed2ca4c2e97caf912ff316be213e191605c61d2934a1a2cd590013a28cfa2
4
+ data.tar.gz: 6e32bf09330d75603b7340f18a58bc9a16d373097d91c2a082ff5fea8a4cb5b8
5
5
  SHA512:
6
- metadata.gz: a2a5f869c3bec9cac04882f15b6d5241468d88bdc2c6d3c205f6db920041f6837c719dbf21812fb450d4a1024819391cbbf184aece064a3eeebea2ef2d8dde22
7
- data.tar.gz: de895fbc4f2718a3c5f016f3f76fbe6d2abcfa22885a2a0bfc84968c937a60403e7b8b2394e6e911bf170c05d6d075daa97588420eced57978b7dad157570991
6
+ metadata.gz: 05bc6522ee2cda61c80dbabeb52a624d3301e6be562ebc575f4508e7537cfa212ba8f8b0f0d14ce4607852dd30162c93d5494325eac4bffe1c0e6f923492c31f
7
+ data.tar.gz: 8537c32ded411934c548b4aa47ca8a03dcf3ed502a927357f25932166f555d0224948776d1226865bea5b01d94deb300081ede84075a64a073eb535175059817
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waylon-core (0.1.5)
4
+ waylon-core (0.1.6)
5
5
  addressable (~> 2.8)
6
6
  faraday (~> 1.8)
7
7
  i18n (~> 1.8)
8
8
  json (~> 2.6)
9
9
  moneta (~> 1.4)
10
10
  puma (~> 5.5)
11
+ rbnacl (~> 7.1)
11
12
  resque (~> 2.2)
12
13
 
13
14
  GEM
@@ -42,6 +43,7 @@ GEM
42
43
  faraday-patron (1.0.0)
43
44
  faraday-rack (1.0.0)
44
45
  faraday-retry (1.0.3)
46
+ ffi (1.15.5)
45
47
  i18n (1.10.0)
46
48
  concurrent-ruby (~> 1.0)
47
49
  json (2.6.2)
@@ -63,6 +65,8 @@ GEM
63
65
  rack
64
66
  rainbow (3.1.1)
65
67
  rake (13.0.6)
68
+ rbnacl (7.1.1)
69
+ ffi
66
70
  redis (4.6.0)
67
71
  redis-namespace (1.8.2)
68
72
  redis (>= 3.0.4)
@@ -127,7 +127,7 @@ module Waylon
127
127
  end
128
128
 
129
129
  # A wrapper for accessing the persistent storage
130
- # @return [Waylon::Storage] The Storage wrapper class
130
+ # @return [Waylon::Storage] The Storage wrapper module
131
131
  def storage
132
132
  Waylon::Storage
133
133
  end
data/lib/waylon/core.rb CHANGED
@@ -21,6 +21,7 @@ require "faraday"
21
21
  require "i18n"
22
22
  require "json"
23
23
  require "moneta"
24
+ require "rbnacl"
24
25
  require "resque"
25
26
  require "sinatra"
26
27
 
@@ -32,6 +33,7 @@ require "waylon/exceptions/not_implemented_error"
32
33
  require "waylon/exceptions/validation_error"
33
34
  require "waylon/group"
34
35
  require "waylon/logger"
36
+ require "waylon/storage"
35
37
  require "waylon/base_component"
36
38
  require "waylon/condition"
37
39
  require "waylon/message"
@@ -20,7 +20,7 @@ config = Waylon::Config.instance
20
20
  config.load_env
21
21
 
22
22
  Waylon::Cache = Moneta.new(:Cookie)
23
- Waylon::Storage = Moneta.new(:LRUHash)
23
+ p Waylon::Storage
24
24
  Waylon::Logger.log("Found Global Admins: #{config.admins}")
25
25
 
26
26
  Waylon::RSpec::TestUser.find_or_create(
data/lib/waylon/rspec.rb CHANGED
@@ -47,4 +47,4 @@ module Waylon
47
47
  end
48
48
 
49
49
  Waylon::Cache = Moneta.new(:Cookie)
50
- Waylon::Storage = Moneta.new(:Cookie)
50
+ Waylon::Storage::Store = Moneta.new(:Cookie)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Waylon
4
+ # Used for working with the Moneta store
5
+ module Storage
6
+ Store = Moneta.new(
7
+ :Redis,
8
+ url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
9
+ )
10
+
11
+ def self.cipher
12
+ key_bytes = RbNaCl::Hash.sha256(ENV.fetch("ENCRYPTION_KEY", "thisisVeryUnsafe4U"))[0..31]
13
+ RbNaCl::SimpleBox.from_secret_key(key_bytes)
14
+ end
15
+
16
+ def self.clear
17
+ Store.clear
18
+ end
19
+
20
+ def self.key?(name)
21
+ Store.key?(name)
22
+ end
23
+
24
+ def self.load(key)
25
+ this_cipher = cipher
26
+ raw = Store.load(key)
27
+ return nil unless raw
28
+
29
+ decoded = Base64.decode64(raw)
30
+ plain = this_cipher.decrypt(decoded)
31
+ JSON.parse(plain)
32
+ end
33
+
34
+ def self.store(key, value)
35
+ this_cipher = cipher
36
+ encrypted = this_cipher.encrypt(value.to_json)
37
+ encoded = Base64.encode64(encrypted)
38
+ Store.store(key, encoded)
39
+ end
40
+ end
41
+ end
@@ -6,7 +6,7 @@ module Waylon
6
6
  VERSION = [
7
7
  0, # Major
8
8
  1, # Minor
9
- 5 # Patch
9
+ 6 # Patch
10
10
  ].join(".")
11
11
  end
12
12
  end
data/scripts/release.sh CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
+ apt-get update && apt-get install -y libsodium-dev
4
+
3
5
  gem install bundler -v '~> 2.3'
4
6
  bundle install
5
7
  rm -rf pkg/*.gem
data/scripts/test.sh CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
+ apt-get update && apt-get install -y libsodium-dev
4
+
3
5
  gem install bundler -v '~> 2.3'
4
6
  bundle install
5
7
  bundle exec rake
data/waylon-core.gemspec CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency "json", "~> 2.6"
34
34
  spec.add_dependency "moneta", "~> 1.4"
35
35
  spec.add_dependency "puma", "~> 5.5"
36
+ spec.add_dependency "rbnacl", "~> 7.1"
36
37
  spec.add_dependency "resque", "~> 2.2"
37
38
 
38
39
  spec.add_development_dependency "bundler", "~> 2.3"
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.1.5
4
+ version: 0.1.6
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-06-07 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '5.5'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rbnacl
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '7.1'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '7.1'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: resque
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -283,6 +297,7 @@ files:
283
297
  - lib/waylon/skills/fun.rb
284
298
  - lib/waylon/skills/groups.rb
285
299
  - lib/waylon/skills/help.rb
300
+ - lib/waylon/storage.rb
286
301
  - lib/waylon/user.rb
287
302
  - lib/waylon/version.rb
288
303
  - lib/waylon/webhook.rb