waylon-core 0.2.3 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/waylon/cache.rb +4 -0
- data/lib/waylon/storage.rb +25 -3
- data/lib/waylon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f127e3f8c3b91cd3d00f5d394ed63e1280d4e84c05f27e6f1526f44edc7b546a
|
4
|
+
data.tar.gz: 44efb8ef9ee90fb8480d873a1a87faad240936085ac379dc634eb81e255792c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53170a69a5676f06c4ec93eda0766728a4c2ee94e1333f82f22b551862af84d6b6407fa3521579c9b8f27681fe575c6073dbf0cd4c5008d9cf3613149e69fef0
|
7
|
+
data.tar.gz: 52b0a7aa10408bef47cbcf0a12e6d517e5e2c9d8012f0ee2fbd83139826cea53f727c6bb4698820bfbe95040103376284dda9c1f4103f5407f74d5944a871a98
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waylon-core (0.2.
|
4
|
+
waylon-core (0.2.6)
|
5
5
|
addressable (~> 2.8)
|
6
6
|
faraday (~> 1.8)
|
7
7
|
i18n (~> 1.8)
|
@@ -73,7 +73,7 @@ GEM
|
|
73
73
|
rake (13.0.6)
|
74
74
|
rbnacl (7.1.1)
|
75
75
|
ffi
|
76
|
-
redis (5.0.
|
76
|
+
redis (5.0.2)
|
77
77
|
redis-client (~> 0.7)
|
78
78
|
redis-client (0.7.1)
|
79
79
|
connection_pool
|
data/lib/waylon/cache.rb
CHANGED
data/lib/waylon/storage.rb
CHANGED
@@ -8,8 +8,12 @@ module Waylon
|
|
8
8
|
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/2"
|
9
9
|
)
|
10
10
|
|
11
|
+
def self.adapter
|
12
|
+
storage.adapter
|
13
|
+
end
|
14
|
+
|
11
15
|
def self.cipher
|
12
|
-
key_bytes = RbNaCl::Hash.sha256(
|
16
|
+
key_bytes = RbNaCl::Hash.sha256(encryption_key)[0..31]
|
13
17
|
RbNaCl::SimpleBox.from_secret_key(key_bytes)
|
14
18
|
end
|
15
19
|
|
@@ -21,6 +25,19 @@ module Waylon
|
|
21
25
|
storage.delete(key)
|
22
26
|
end
|
23
27
|
|
28
|
+
def self.each_key(&block)
|
29
|
+
storage.each_key(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.encryption_key
|
33
|
+
ENV.fetch("ENCRYPTION_KEY", "thisisVeryUnsafe4U")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.encryption_key_fingerprint
|
37
|
+
base = RbNaCl::Hash.sha256(encryption_key)[0..15]
|
38
|
+
Base64.urlsafe_encode64(RbNaCl::Hash.sha256(base)[0..7])
|
39
|
+
end
|
40
|
+
|
24
41
|
def self.key?(name)
|
25
42
|
storage.key?(name)
|
26
43
|
end
|
@@ -30,7 +47,11 @@ module Waylon
|
|
30
47
|
raw = storage.load(key)
|
31
48
|
return nil unless raw
|
32
49
|
|
33
|
-
|
50
|
+
wrapper = JSON.parse(raw)
|
51
|
+
value = wrapper["data"]
|
52
|
+
return nil unless value
|
53
|
+
|
54
|
+
decoded = Base64.decode64(value)
|
34
55
|
plain = this_cipher.decrypt(decoded)
|
35
56
|
JSON.parse(plain)
|
36
57
|
end
|
@@ -47,7 +68,8 @@ module Waylon
|
|
47
68
|
this_cipher = cipher
|
48
69
|
encrypted = this_cipher.encrypt(value.to_json)
|
49
70
|
encoded = Base64.encode64(encrypted)
|
50
|
-
|
71
|
+
wrapper = { cipher: cipher.class.name, data: encoded, key: encryption_key_fingerprint }
|
72
|
+
storage.store(key, wrapper.to_json)
|
51
73
|
end
|
52
74
|
end
|
53
75
|
end
|
data/lib/waylon/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2022-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|