waylon-core 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/waylon/storage.rb +17 -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: 0d0e47ec62eadd0848b4538d1bb32238b7e769f09500d536925cbd7d4367be68
|
4
|
+
data.tar.gz: 0ecd0c0d42d07861138d8df7170cb49f9eab7bf9a142844bbca44c57d1222bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9dcad0d9c4ad06afa6579d0a38daa70733fc8a0c692fb9f12b52ddd49f4ab998768ffbd92bfe7fc3a54b5b6691f91f4719c882d730e824364ea5adb190119b3
|
7
|
+
data.tar.gz: 94867f2bb0fde6993ded3026d827c36dbc4af5e3979281a005feea6f202a2e59a700b72ad2bf368d16add33eee9e631451d9aba76b38eb38d04a9c422097e234
|
data/Gemfile.lock
CHANGED
data/lib/waylon/storage.rb
CHANGED
@@ -9,7 +9,7 @@ module Waylon
|
|
9
9
|
)
|
10
10
|
|
11
11
|
def self.cipher
|
12
|
-
key_bytes = RbNaCl::Hash.sha256(
|
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
|
-
|
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
|
-
|
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
|
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.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-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|